LLPointer<LLIMInfo> llsd_to_im_info(const LLSD& im_info_sd) { LLSD param_message = im_info_sd["message_params"]; LLSD param_agent = im_info_sd["agent_params"]; LLPointer<LLIMInfo> im_info = new LLIMInfo( param_message["from_id"].asUUID(), param_message["from_group"].asBoolean(), param_message["to_id"].asUUID(), (EInstantMessage) param_message["type"].asInteger(), param_message["from_name"].asString(), param_message["message"].asString(), param_message["id"].asUUID(), (U32) param_message["parent_estate_id"].asInteger(), im_info->mRegionID = param_message["region_id"].asUUID(), ll_vector3_from_sd(param_message["position"]), param_message["data"], (U8) param_message["offline"].asInteger(), (U32) param_message["timestamp"].asInteger(), (EIMSource)param_message["source"].asInteger(), param_message["ttl"].asInteger()); return im_info; }
void LLAgentListener::lookAt(LLSD const & event_data) const { LLViewerObject *object = NULL; if (event_data.has("obj_uuid")) { object = gObjectList.findObject(event_data["obj_uuid"]); } else if (event_data.has("position")) { LLVector3 target_position = ll_vector3_from_sd(event_data["position"]); object = findObjectClosestTo(target_position); } S32 look_at_type = (S32) LOOKAT_TARGET_NONE; if (event_data.has("type")) { look_at_type = event_data["type"].asInteger(); } if (look_at_type >= (S32) LOOKAT_TARGET_NONE && look_at_type < (S32) LOOKAT_NUM_TARGETS) { gAgentCamera.setLookAt((ELookAtType) look_at_type, object); } }
void LLPanelScriptLimitsRegionMemory::setRegionDetails(LLSD content) { LLScrollListCtrl *list = getChild<LLScrollListCtrl>("scripts_list"); if(!list) { llwarns << "Error getting the scripts_list control" << llendl; return; } S32 number_parcels = content["parcels"].size(); LLStringUtil::format_map_t args_parcels; args_parcels["[PARCELS]"] = llformat ("%d", number_parcels); std::string msg_parcels = LLTrans::getString("ScriptLimitsParcelsOwned", args_parcels); childSetValue("parcels_listed", LLSD(msg_parcels)); std::vector<LLUUID> names_requested; // This makes the assumption that all objects will have the same set // of attributes, ie they will all have, or none will have locations // This is a pretty safe assumption as it's reliant on server version. bool has_locations = false; bool has_local_ids = false; for(S32 i = 0; i < number_parcels; i++) { std::string parcel_name = content["parcels"][i]["name"].asString(); LLUUID parcel_id = content["parcels"][i]["id"].asUUID(); S32 number_objects = content["parcels"][i]["objects"].size(); S32 local_id = 0; if(content["parcels"][i].has("local_id")) { // if any locations are found flag that we can use them and turn on the highlight button has_local_ids = true; local_id = content["parcels"][i]["local_id"].asInteger(); } for(S32 j = 0; j < number_objects; j++) { S32 size = content["parcels"][i]["objects"][j]["resources"]["memory"].asInteger() / SIZE_OF_ONE_KB; S32 urls = content["parcels"][i]["objects"][j]["resources"]["urls"].asInteger(); std::string name_buf = content["parcels"][i]["objects"][j]["name"].asString(); LLUUID task_id = content["parcels"][i]["objects"][j]["id"].asUUID(); LLUUID owner_id = content["parcels"][i]["objects"][j]["owner_id"].asUUID(); F32 location_x = 0.0f; F32 location_y = 0.0f; F32 location_z = 0.0f; if(content["parcels"][i]["objects"][j].has("location")) { // if any locations are found flag that we can use them and turn on the highlight button LLVector3 vec = ll_vector3_from_sd(content["parcels"][i]["objects"][j]["location"]); has_locations = true; location_x = vec.mV[0]; location_y = vec.mV[1]; location_z = vec.mV[2]; } std::string owner_buf; // in the future the server will give us owner names, so see if we're there yet: if(content["parcels"][i]["objects"][j].has("owner_name")) { owner_buf = content["parcels"][i]["objects"][j]["owner_name"].asString(); } // ...and if not use the slightly more painful method of disovery: else { BOOL name_is_cached = gCacheName->getFullName(owner_id, owner_buf); if(!name_is_cached) { if(std::find(names_requested.begin(), names_requested.end(), owner_id) == names_requested.end()) { names_requested.push_back(owner_id); gCacheName->get(owner_id, TRUE, boost::bind(&LLPanelScriptLimitsRegionMemory::onNameCache, this, _1, _2, _3)); } } } LLSD element; element["id"] = task_id; element["columns"][0]["column"] = "size"; element["columns"][0]["value"] = llformat("%d", size); element["columns"][0]["font"] = "SANSSERIF"; element["columns"][1]["column"] = "urls"; element["columns"][1]["value"] = llformat("%d", urls); element["columns"][1]["font"] = "SANSSERIF"; element["columns"][2]["column"] = "name"; element["columns"][2]["value"] = name_buf; element["columns"][2]["font"] = "SANSSERIF"; element["columns"][3]["column"] = "owner"; element["columns"][3]["value"] = owner_buf; element["columns"][3]["font"] = "SANSSERIF"; element["columns"][4]["column"] = "parcel"; element["columns"][4]["value"] = parcel_name; element["columns"][4]["font"] = "SANSSERIF"; element["columns"][5]["column"] = "location"; if(has_locations) { element["columns"][5]["value"] = llformat("<%0.1f,%0.1f,%0.1f>", location_x, location_y, location_z); } else { element["columns"][5]["value"] = ""; } element["columns"][5]["font"] = "SANSSERIF"; list->addElement(element, ADD_SORTED); element["owner_id"] = owner_id; element["local_id"] = local_id; mObjectListItems.push_back(element); } } if (has_locations) { LLButton* btn = getChild<LLButton>("highlight_btn"); if(btn) { btn->setVisible(true); } } if (has_local_ids) { LLButton* btn = getChild<LLButton>("return_btn"); if(btn) { btn->setVisible(true); } } // save the structure to make object return easier mContent = content; }
//LLImportObject::LLImportObject(std::string id, std::string parentId) // : LLViewerObject(LLUUID::null, 9, NULL, TRUE), // mId(id), // mParentId(parentId), // mPrimName("Object") //{ // importIsAttachment = false; //} LLImportObject::LLImportObject(std::string id, LLSD prim) : LLViewerObject(LLUUID::null, 9, NULL, TRUE) { importIsAttachment = false; mId = id; mParentId = ""; mPrimName = "Object"; if(prim.has("parent")) { mParentId = prim["parent"].asString(); } // Stuff for attach if(prim.has("attach")) { importIsAttachment = true; importAttachPoint = (U8)prim["attach"].asInteger(); importAttachPos = ll_vector3_from_sd(prim["position"]); importAttachRot = ll_quaternion_from_sd(prim["rotation"]); } // Transforms setPosition(ll_vector3_from_sd(prim["position"]), FALSE); setScale(ll_vector3_from_sd(prim["scale"]), FALSE); setRotation(ll_quaternion_from_sd(prim["rotation"]), FALSE); // Flags setFlags(FLAGS_CAST_SHADOWS, prim["shadows"].asInteger()); setFlags(FLAGS_PHANTOM, prim["phantom"].asInteger()); setFlags(FLAGS_USE_PHYSICS, prim["physical"].asInteger()); // Volume params LLVolumeParams volume_params; volume_params.fromLLSD(prim["volume"]); setVolume(volume_params, 0, false); // Extra params if(prim.has("flexible")) { LLFlexibleObjectData* wat = new LLFlexibleObjectData(); wat->fromLLSD(prim["flex"]); LLFlexibleObjectData flex = *wat; setParameterEntry(LLNetworkData::PARAMS_FLEXIBLE, flex, true); setParameterEntryInUse(LLNetworkData::PARAMS_FLEXIBLE, TRUE, true); } if(prim.has("light")) { LLLightParams* wat = new LLLightParams(); wat->fromLLSD(prim["light"]); LLLightParams light = *wat; setParameterEntry(LLNetworkData::PARAMS_LIGHT, light, true); setParameterEntryInUse(LLNetworkData::PARAMS_LIGHT, TRUE, true); } if(prim.has("sculpt")) { LLSculptParams *wat = new LLSculptParams(); wat->fromLLSD(prim["sculpt"]); LLSculptParams sculpt = *wat; if(sculpt.getSculptType() == 5)//5 is apparently mesh... yeah. { llinfos << "Oh no mesh, f**k you." << llendl; sculpt.setSculptType(0);//f**k you } setParameterEntry(LLNetworkData::PARAMS_SCULPT, sculpt, true); setParameterEntryInUse(LLNetworkData::PARAMS_SCULPT, TRUE, true); } // Textures LLSD textures = prim["textures"]; LLSD::array_iterator array_iter = textures.beginArray(); LLSD::array_iterator array_end = textures.endArray(); int i = 0; for( ; array_iter != array_end; ++array_iter) { LLTextureEntry* wat = new LLTextureEntry(); wat->fromLLSD(*array_iter); LLTextureEntry te = *wat; delete wat; //clean up yo memory mTextures.push_back(te.getID()); setTE(i, te); i++; } mTextures.unique(); if(prim.has("name")) { mPrimName = prim["name"].asString(); } if(prim.has("description")) { mPrimDescription = prim["description"].asString(); } }
//virtual void LLSDMessageReader::getVector3(const char *block, const char *var, LLVector3 &vec, S32 blocknum) { vec = ll_vector3_from_sd(getLLSD(mMessage, block, var, blocknum)); }
virtual void post( ResponsePtr response, const LLSD& context, const LLSD& input) const { //for backwards compatiblity reasons...we need to still //check for 'text' or 'voice' invitations...bleh if ( input["body"].has("instantmessage") ) { LLSD message_params = input["body"]["instantmessage"]["message_params"]; //do something here to have the IM invite behave //just like a normal IM //this is just replicated code from process_improved_im //and should really go in it's own function -jwolk if (gNoRender) { return; } LLChat chat; std::string message = message_params["message"].asString(); std::string name = message_params["from_name"].asString(); LLUUID from_id = message_params["from_id"].asUUID(); LLUUID session_id = message_params["id"].asUUID(); std::vector<U8> bin_bucket = message_params["data"]["binary_bucket"].asBinary(); U8 offline = (U8)message_params["offline"].asInteger(); time_t timestamp = (time_t) message_params["timestamp"].asInteger(); BOOL is_busy = gAgent.getBusy(); BOOL is_muted = LLMuteList::getInstance()->isMuted( from_id, name, LLMute::flagTextChat); BOOL is_linden = LLMuteList::getInstance()->isLinden(name); std::string separator_string(": "); int message_offset=0; //Handle IRC styled /me messages. std::string prefix = message.substr(0, 4); if (prefix == "/me " || prefix == "/me'") { separator_string = ""; message_offset = 3; } chat.mMuted = is_muted && !is_linden; chat.mFromID = from_id; chat.mFromName = name; if (!is_linden && (is_busy || is_muted)) { return; } // [RLVa:KB] - Checked: 2010-11-30 (RLVa-1.3.0c) | Modified: RLVa-1.3.0c if ( (gRlvHandler.hasBehaviour(RLV_BHVR_RECVIM)) || (gRlvHandler.hasBehaviour(RLV_BHVR_RECVIMFROM)) ) { if (gAgent.isInGroup(session_id)) // Group chat: don't accept the invite if not an exception { if (!gRlvHandler.canReceiveIM(session_id)) return; } else if (!gRlvHandler.canReceiveIM(from_id)) // Conference chat: don't block; censor if not an exception { message = RlvStrings::getString(RLV_STRING_BLOCKED_RECVIM); } } // [/RLVa:KB] // standard message, not from system std::string saved; if(offline == IM_OFFLINE) { saved = llformat("(Saved %s) ", formatted_time(timestamp).c_str()); } std::string buffer = separator_string + saved + message.substr(message_offset); BOOL is_this_agent = FALSE; if(from_id == gAgentID) { is_this_agent = TRUE; } gIMMgr->addMessage( session_id, from_id, name, buffer, std::string((char*)&bin_bucket[0]), IM_SESSION_INVITE, message_params["parent_estate_id"].asInteger(), message_params["region_id"].asUUID(), ll_vector3_from_sd(message_params["position"]), true); LLGroupData group_data; gAgent.getGroupData(session_id, group_data); std::string prepend_msg; if (gAgent.isInGroup(session_id)&& gSavedSettings.getBOOL("OptionShowGroupNameInChatIM")) { prepend_msg = "["; prepend_msg += group_data.mName; prepend_msg += "] "; } else { prepend_msg = std::string("IM: "); } chat.mText = prepend_msg + name + separator_string + saved + message.substr(message_offset); LLFloaterChat::addChat(chat, TRUE, is_this_agent); //K now we want to accept the invitation std::string url = gAgent.getRegion()->getCapability( "ChatSessionRequest"); if ( url != "" ) { LLSD data; data["method"] = "accept invitation"; data["session-id"] = session_id; LLHTTPClient::post( url, data, new LLViewerChatterBoxInvitationAcceptResponder( session_id, LLIMMgr::INVITATION_TYPE_INSTANT_MESSAGE)); } } //end if invitation has instant message else if ( input["body"].has("voice") ) { if (gNoRender) { return; } if(!LLVoiceClient::voiceEnabled()) { // Don't display voice invites unless the user has voice enabled. return; } gIMMgr->inviteToSession( input["body"]["session_id"].asUUID(), input["body"]["session_name"].asString(), input["body"]["from_id"].asUUID(), input["body"]["from_name"].asString(), IM_SESSION_INVITE, LLIMMgr::INVITATION_TYPE_VOICE); } else if ( input["body"].has("immediate") ) { gIMMgr->inviteToSession( input["body"]["session_id"].asUUID(), input["body"]["session_name"].asString(), input["body"]["from_id"].asUUID(), input["body"]["from_name"].asString(), IM_SESSION_INVITE, LLIMMgr::INVITATION_TYPE_IMMEDIATE); } }
virtual void post( ResponsePtr response, const LLSD& context, const LLSD& input) const { //for backwards compatiblity reasons...we need to still //check for 'text' or 'voice' invitations...bleh if ( input["body"].has("instantmessage") ) { LLSD message_params = input["body"]["instantmessage"]["message_params"]; //do something here to have the IM invite behave //just like a normal IM //this is just replicated code from process_improved_im //and should really go in it's own function -jwolk if (gNoRender) { return; } LLChat chat; std::string message = message_params["message"].asString(); std::string name = message_params["from_name"].asString(); LLUUID from_id = message_params["from_id"].asUUID(); LLUUID session_id = message_params["id"].asUUID(); std::vector<U8> bin_bucket = message_params["data"]["binary_bucket"].asBinary(); U8 offline = (U8)message_params["offline"].asInteger(); time_t timestamp = (time_t) message_params["timestamp"].asInteger(); BOOL is_busy = gAgent.getBusy(); BOOL is_muted = LLMuteList::getInstance()->isMuted( from_id, name, LLMute::flagTextChat); BOOL is_linden = LLMuteList::getInstance()->isLinden(name); std::string separator_string(": "); int message_offset=0; //Handle IRC styled /me messages. std::string prefix = message.substr(0, 4); if (prefix == "/me " || prefix == "/me'") { separator_string = ""; message_offset = 3; } chat.mMuted = is_muted && !is_linden; chat.mFromID = from_id; chat.mFromName = name; if (!is_linden && (is_busy || is_muted)) { return; } // [RLVa:KB] - Checked: 2009-07-10 (RLVa-1.0.0g) // TODO-RLVa: duplicate from process_improved_im()? if (gRlvHandler.hasBehaviour(RLV_BHVR_RECVIM)) { if (gAgent.isInGroup(session_id)) { if (!gRlvHandler.isException(RLV_BHVR_RECVIM, session_id)) return; } else if (!gRlvHandler.isException(RLV_BHVR_RECVIM, from_id)) message = message.substr(0, message_offset) + RlvStrings::getString(RLV_STRING_BLOCKED_RECVIM); } // [/RLVa:KB] //Kadah - PHOE-277: fix for group chat still coming thru on console when disabled static LLCachedControl<BOOL> PhoenixMuteAllGroups("PhoenixMuteAllGroups", 0); static LLCachedControl<BOOL> PhoenixMuteGroupWhenNoticesDisabled("PhoenixMuteGroupWhenNoticesDisabled", 0); LLGroupData group_data; if (gAgent.getGroupData(session_id, group_data)) { if (PhoenixMuteAllGroups || (PhoenixMuteGroupWhenNoticesDisabled && !group_data.mAcceptNotices)) { llinfos << "Phoenix: muting group chat: " << group_data.mName << LL_ENDL; if(gSavedSettings.getBOOL("PhoenixNotifyWhenMutingGroupChat")) { LLChat chat; chat.mText = "[Muting group chat: " + group_data.mName + "]"; chat.mSourceType = CHAT_SOURCE_SYSTEM; LLFloaterChat::addChat(chat, FALSE, FALSE); } //KC: make sure we leave the group chat at the server end as well std::string aname; gAgent.buildFullname(aname); pack_instant_message( gMessageSystem, gAgent.getID(), FALSE, gAgent.getSessionID(), from_id, aname, LLStringUtil::null, IM_ONLINE, IM_SESSION_LEAVE, session_id); gAgent.sendReliableMessage(); gIMMgr->removeSession(session_id); return; } } // standard message, not from system std::string saved; if(offline == IM_OFFLINE) { saved = llformat("(Saved %s) ", formatted_time(timestamp).c_str()); } std::string buffer = separator_string + saved + message.substr(message_offset); BOOL is_this_agent = FALSE; if(from_id == gAgentID) { is_this_agent = TRUE; } gIMMgr->addMessage( session_id, from_id, name, buffer, std::string((char*)&bin_bucket[0]), IM_SESSION_INVITE, message_params["parent_estate_id"].asInteger(), message_params["region_id"].asUUID(), ll_vector3_from_sd(message_params["position"]), true); std::string prepend_msg; if (gAgent.isInGroup(session_id)&& gSavedSettings.getBOOL("DiamondShowGroupNameInChatIM")) { std::string tmp = group_data.mName; prepend_msg = "["; prepend_msg += tmp.substr(0,gSavedSettings.getS32("DiamondShowGroupNameLength")); prepend_msg += "] "; } else { prepend_msg = std::string("IM: "); } chat.mText = prepend_msg + name + separator_string + saved + message.substr(message_offset); LLFloaterChat::addChat(chat, TRUE, is_this_agent); // Growl alert if a keyword is picked up. (KC - Maybe this should be here so the first message of a chat conv can be check too?) if(from_id != gAgent.getID() && MfdKeywordFloaterStart::hasKeyword(message, MfdKeywordFloaterStart::PrivateMessage)) gGrowlManager->notify("Keyword Alert", chat.mText, "Keyword Alert"); //K now we want to accept the invitation std::string url = gAgent.getRegion()->getCapability( "ChatSessionRequest"); if ( url != "" ) { LLSD data; data["method"] = "accept invitation"; data["session-id"] = session_id; LLHTTPClient::post( url, data, new LLViewerChatterBoxInvitationAcceptResponder( session_id, LLIMMgr::INVITATION_TYPE_INSTANT_MESSAGE)); } } //end if invitation has instant message else if ( input["body"].has("voice") ) { if (gNoRender) { return; } if(!LLVoiceClient::voiceEnabled()) { // Don't display voice invites unless the user has voice enabled. return; } gIMMgr->inviteToSession( input["body"]["session_id"].asUUID(), input["body"]["session_name"].asString(), input["body"]["from_id"].asUUID(), input["body"]["from_name"].asString(), IM_SESSION_INVITE, LLIMMgr::INVITATION_TYPE_VOICE); } else if ( input["body"].has("immediate") ) { gIMMgr->inviteToSession( input["body"]["session_id"].asUUID(), input["body"]["session_name"].asString(), input["body"]["from_id"].asUUID(), input["body"]["from_name"].asString(), IM_SESSION_INVITE, LLIMMgr::INVITATION_TYPE_IMMEDIATE); } }
void LLPanelScriptLimitsRegionMemory::setRegionDetails(LLSD content) { LLScrollListCtrl *list = getChild<LLScrollListCtrl>("scripts_list"); if(!list) { LL_WARNS() << "Error getting the scripts_list control" << LL_ENDL; return; } S32 number_parcels = content["parcels"].size(); LLStringUtil::format_map_t args_parcels; args_parcels["[PARCELS]"] = llformat ("%d", number_parcels); std::string msg_parcels = LLTrans::getString("ScriptLimitsParcelsOwned", args_parcels); getChild<LLUICtrl>("parcels_listed")->setValue(LLSD(msg_parcels)); uuid_vec_t names_requested; // This makes the assumption that all objects will have the same set // of attributes, ie they will all have, or none will have locations // This is a pretty safe assumption as it's reliant on server version. bool has_locations = false; bool has_local_ids = false; for(S32 i = 0; i < number_parcels; i++) { std::string parcel_name = content["parcels"][i]["name"].asString(); LLUUID parcel_id = content["parcels"][i]["id"].asUUID(); S32 number_objects = content["parcels"][i]["objects"].size(); S32 local_id = 0; if(content["parcels"][i].has("local_id")) { // if any locations are found flag that we can use them and turn on the highlight button has_local_ids = true; local_id = content["parcels"][i]["local_id"].asInteger(); } for(S32 j = 0; j < number_objects; j++) { S32 size = content["parcels"][i]["objects"][j]["resources"]["memory"].asInteger() / SIZE_OF_ONE_KB; S32 urls = content["parcels"][i]["objects"][j]["resources"]["urls"].asInteger(); std::string name_buf = content["parcels"][i]["objects"][j]["name"].asString(); LLUUID task_id = content["parcels"][i]["objects"][j]["id"].asUUID(); LLUUID owner_id = content["parcels"][i]["objects"][j]["owner_id"].asUUID(); // This field may not be sent by all server versions, but it's OK if // it uses the LLSD default of false bool is_group_owned = content["parcels"][i]["objects"][j]["is_group_owned"].asBoolean(); F32 location_x = 0.0f; F32 location_y = 0.0f; F32 location_z = 0.0f; if(content["parcels"][i]["objects"][j].has("location")) { // if any locations are found flag that we can use them and turn on the highlight button LLVector3 vec = ll_vector3_from_sd(content["parcels"][i]["objects"][j]["location"]); has_locations = true; location_x = vec.mV[0]; location_y = vec.mV[1]; location_z = vec.mV[2]; } std::string owner_buf; // in the future the server will give us owner names, so see if we're there yet: if(content["parcels"][i]["objects"][j].has("owner_name")) { owner_buf = content["parcels"][i]["objects"][j]["owner_name"].asString(); } // ...and if not use the slightly more painful method of disovery: else { BOOL name_is_cached; if (is_group_owned) { name_is_cached = gCacheName->getGroupName(owner_id, owner_buf); } else { name_is_cached = LLAvatarNameCache::getNSName(owner_id, owner_buf); // username } if(!name_is_cached) { if(std::find(names_requested.begin(), names_requested.end(), owner_id) == names_requested.end()) { names_requested.push_back(owner_id); gCacheName->get(owner_id, is_group_owned, // username boost::bind(&LLPanelScriptLimitsRegionMemory::onNameCache, this, _1, _2)); } } } LLScrollListItem::Params item_params; item_params.value = task_id; LLScrollListCell::Params cell_params; //cell_params.font = LLFontGL::getFontSansSerif(); cell_params.column = "size"; cell_params.value = size; item_params.columns.add(cell_params); cell_params.column = "urls"; cell_params.value = urls; item_params.columns.add(cell_params); cell_params.column = "name"; cell_params.value = name_buf; item_params.columns.add(cell_params); cell_params.column = "owner"; cell_params.value = owner_buf; item_params.columns.add(cell_params); cell_params.column = "parcel"; cell_params.value = parcel_name; item_params.columns.add(cell_params); cell_params.column = "location"; cell_params.value = has_locations ? llformat("<%0.1f,%0.1f,%0.1f>", location_x, location_y, location_z) : ""; item_params.columns.add(cell_params); list->addRow(item_params); LLSD element; element["owner_id"] = owner_id; element["id"] = task_id; element["local_id"] = local_id; mObjectListItems.push_back(element); } } if (has_locations) { LLButton* btn = getChild<LLButton>("highlight_btn"); if(btn) { btn->setVisible(true); } } if (has_local_ids) { LLButton* btn = getChild<LLButton>("return_btn"); if(btn) { btn->setVisible(true); } } // save the structure to make object return easier mContent = content; }