bool LLPartData::fromLLSD(LLSD& sd) { mFlags = ll_U32_from_sd(sd["pdflags"]); mMaxAge = (F32)sd["pdmaxage"].asReal(); mStartColor = ll_color4_from_sd(sd["pdstartcolor"]); mEndColor = ll_color4_from_sd(sd["pdendcolor"]); mStartScale = ll_vector2_from_sd(sd["pdstartscale"]); mEndScale = ll_vector2_from_sd(sd["pdendscale"]); return true; }
void MediaPluginCEF::unicodeInput(const std::string &utf8str, LLCEFLib::EKeyboardModifier modifiers, LLSD native_key_data = LLSD::emptyMap()) { #if LL_DARWIN //mLLCEFLib->keyPress(utf8str[0], true); //mLLCEFLib->keyboardEvent(LLCEFLib::KE_KEY_DOWN, (uint32_t)(utf8str[0]), 0, LLCEFLib::KM_MODIFIER_NONE, 0, 0, 0); if (!native_key_data.has("event_chars") || !native_key_data.has("event_umodchars") || !native_key_data.has("event_keycode") || !native_key_data.has("event_modifiers")) return; uint32_t unicodeChar = native_key_data["event_chars"].asInteger(); uint32_t unmodifiedChar = native_key_data["event_umodchars"].asInteger(); uint32_t keyCode = native_key_data["event_keycode"].asInteger(); uint32_t rawmodifiers = native_key_data["event_modifiers"].asInteger(); mLLCEFLib->injectUnicodeText(unicodeChar, unmodifiedChar, keyCode, rawmodifiers); #elif LL_WINDOWS U32 msg = ll_U32_from_sd(native_key_data["msg"]); U32 wparam = ll_U32_from_sd(native_key_data["w_param"]); U64 lparam = ll_U32_from_sd(native_key_data["l_param"]); mLLCEFLib->nativeKeyboardEvent(msg, wparam, lparam); #endif };
bool LLSaleInfo::fromLLSD(LLSD& sd, BOOL& has_perm_mask, U32& perm_mask) { const char *w; mSaleType = lookup(sd["sale_type"].asString().c_str()); mSalePrice = llclamp(sd["sale_price"].asInteger(), 0, S32_MAX); w = "perm_mask"; if (sd.has(w)) { has_perm_mask = TRUE; perm_mask = ll_U32_from_sd(sd[w]); } return true; }
void MediaPluginCEF::keyEvent(LLCEFLib::EKeyEvent key_event, int key, LLCEFLib::EKeyboardModifier modifiers_x, LLSD native_key_data = LLSD::emptyMap()) { #if LL_DARWIN if (!native_key_data.has("event_type") || !native_key_data.has("event_modifiers") || !native_key_data.has("event_keycode") || !native_key_data.has("event_isrepeat")) return; uint32_t eventType = native_key_data["event_type"].asInteger(); if (!eventType) return; uint32_t eventModifiers = native_key_data["event_modifiers"].asInteger(); uint32_t eventKeycode = native_key_data["event_keycode"].asInteger(); char eventChars = static_cast<char>(native_key_data["event_chars"].isUndefined() ? 0 : native_key_data["event_chars"].asInteger()); char eventUChars = static_cast<char>(native_key_data["event_umodchars"].isUndefined() ? 0 : native_key_data["event_umodchars"].asInteger()); bool eventIsRepeat = native_key_data["event_isrepeat"].asBoolean(); mLLCEFLib->keyboardEventOSX(eventType, eventModifiers, (eventChars) ? &eventChars : NULL, (eventUChars) ? &eventUChars : NULL, eventIsRepeat, eventKeycode); #elif LL_WINDOWS U32 msg = ll_U32_from_sd(native_key_data["msg"]); U32 wparam = ll_U32_from_sd(native_key_data["w_param"]); U64 lparam = ll_U32_from_sd(native_key_data["l_param"]); mLLCEFLib->nativeKeyboardEvent(msg, wparam, lparam); #elif LL_LINUX uint32_t native_scan_code = 0; uint32_t native_virtual_key = 0; uint32_t native_modifiers = 0; deserializeKeyboardData(native_key_data, native_scan_code, native_virtual_key, native_modifiers); mLLCEFLib->nativeKeyboardEvent(key_event, native_scan_code, native_virtual_key, native_modifiers); #endif }
bool LLSaleInfo::fromLLSD(const LLSD& sd, BOOL& has_perm_mask, U32& perm_mask) { const char *w; if (sd["sale_type"].isString()) { mSaleType = lookup(sd["sale_type"].asString().c_str()); } else if(sd["sale_type"].isInteger()) { S8 type = (U8)sd["sale_type"].asInteger(); mSaleType = static_cast<LLSaleInfo::EForSale>(type); } mSalePrice = llclamp(sd["sale_price"].asInteger(), 0, S32_MAX); w = "perm_mask"; if (sd.has(w)) { has_perm_mask = TRUE; perm_mask = ll_U32_from_sd(sd[w]); } return true; }
bool LLInventoryItem::fromLLSD(LLSD& sd) { mInventoryType = LLInventoryType::IT_NONE; mAssetUUID.setNull(); std::string w; w = INV_ITEM_ID_LABEL; if (sd.has(w)) { mUUID = sd[w]; } w = INV_PARENT_ID_LABEL; if (sd.has(w)) { mParentUUID = sd[w]; } w = INV_PERMISSIONS_LABEL; if (sd.has(w)) { mPermissions = ll_permissions_from_sd(sd[w]); } w = INV_SALE_INFO_LABEL; if (sd.has(w)) { // Sale info used to contain next owner perm. It is now in // the permissions. Thus, we read that out, and fix legacy // objects. It's possible this op would fail, but it // should pick up the vast majority of the tasks. BOOL has_perm_mask = FALSE; U32 perm_mask = 0; if (!mSaleInfo.fromLLSD(sd[w], has_perm_mask, perm_mask)) { goto fail; } if (has_perm_mask) { if(perm_mask == PERM_NONE) { perm_mask = mPermissions.getMaskOwner(); } // fair use fix. if(!(perm_mask & PERM_COPY)) { perm_mask |= PERM_TRANSFER; } mPermissions.setMaskNext(perm_mask); } } w = INV_SHADOW_ID_LABEL; if (sd.has(w)) { mAssetUUID = sd[w]; LLXORCipher cipher(MAGIC_ID.mData, UUID_BYTES); cipher.decrypt(mAssetUUID.mData, UUID_BYTES); } w = INV_ASSET_ID_LABEL; if (sd.has(w)) { mAssetUUID = sd[w]; } w = INV_ASSET_TYPE_LABEL; if (sd.has(w)) { if (sd[w].isString()) { mType = LLAssetType::lookup(sd[w].asString().c_str()); } else if (sd[w].isInteger()) { S8 type = (U8)sd[w].asInteger(); mType = static_cast<LLAssetType::EType>(type); } } w = INV_INVENTORY_TYPE_LABEL; if (sd.has(w)) { if (sd[w].isString()) { mInventoryType = LLInventoryType::lookup(sd[w].asString().c_str()); } else if (sd[w].isInteger()) { S8 type = (U8)sd[w].asInteger(); mInventoryType = static_cast<LLInventoryType::EType>(type); } } w = INV_FLAGS_LABEL; if (sd.has(w)) { if (sd[w].isBinary()) { mFlags = ll_U32_from_sd(sd[w]); } else if(sd[w].isInteger()) { mFlags = sd[w].asInteger(); } } w = INV_NAME_LABEL; if (sd.has(w)) { mName = sd[w].asString(); LLStringUtil::replaceNonstandardASCII(mName, ' '); LLStringUtil::replaceChar(mName, '|', ' '); } w = INV_DESC_LABEL; if (sd.has(w)) { mDescription = sd[w].asString(); LLStringUtil::replaceNonstandardASCII(mDescription, ' '); } w = INV_CREATION_DATE_LABEL; if (sd.has(w)) { mCreationDate = sd[w].asInteger(); } // Need to convert 1.0 simstate files to a useful inventory type // and potentially deal with bad inventory tyes eg, a landmark // marked as a texture. if((LLInventoryType::IT_NONE == mInventoryType) || !inventory_and_asset_types_match(mInventoryType, mType)) { lldebugs << "Resetting inventory type for " << mUUID << llendl; mInventoryType = LLInventoryType::defaultForAssetType(mType); } return true; fail: return false; }
//virtual void LLSDMessageReader::getU32(const char *block, const char *var, U32 &data, S32 blocknum) { data = ll_U32_from_sd(getLLSD(mMessage, block, var, blocknum)); }
bool LLInventoryItem::fromLLSD(const LLSD& sd, bool is_new) { LL_RECORD_BLOCK_TIME(FTM_INVENTORY_SD_DESERIALIZE); if (is_new) { // If we're adding LLSD to an existing object, need avoid // clobbering these fields. mInventoryType = LLInventoryType::IT_NONE; mAssetUUID.setNull(); } std::string w; w = INV_ITEM_ID_LABEL; if (sd.has(w)) { mUUID = sd[w]; } w = INV_PARENT_ID_LABEL; if (sd.has(w)) { mParentUUID = sd[w]; } w = INV_PERMISSIONS_LABEL; if (sd.has(w)) { mPermissions = ll_permissions_from_sd(sd[w]); } w = INV_SALE_INFO_LABEL; if (sd.has(w)) { // Sale info used to contain next owner perm. It is now in // the permissions. Thus, we read that out, and fix legacy // objects. It's possible this op would fail, but it // should pick up the vast majority of the tasks. BOOL has_perm_mask = FALSE; U32 perm_mask = 0; if (!mSaleInfo.fromLLSD(sd[w], has_perm_mask, perm_mask)) { goto fail; } if (has_perm_mask) { if(perm_mask == PERM_NONE) { perm_mask = mPermissions.getMaskOwner(); } // fair use fix. if(!(perm_mask & PERM_COPY)) { perm_mask |= PERM_TRANSFER; } mPermissions.setMaskNext(perm_mask); } } w = INV_SHADOW_ID_LABEL; if (sd.has(w)) { mAssetUUID = sd[w]; LLXORCipher cipher(MAGIC_ID.mData, UUID_BYTES); cipher.decrypt(mAssetUUID.mData, UUID_BYTES); } w = INV_ASSET_ID_LABEL; if (sd.has(w)) { mAssetUUID = sd[w]; } w = INV_LINKED_ID_LABEL; if (sd.has(w)) { mAssetUUID = sd[w]; } w = INV_ASSET_TYPE_LABEL; if (sd.has(w)) { if (sd[w].isString()) { mType = LLAssetType::lookup(sd[w].asString().c_str()); } else if (sd[w].isInteger()) { S8 type = (U8)sd[w].asInteger(); mType = static_cast<LLAssetType::EType>(type); } } w = INV_INVENTORY_TYPE_LABEL; if (sd.has(w)) { if (sd[w].isString()) { mInventoryType = LLInventoryType::lookup(sd[w].asString().c_str()); } else if (sd[w].isInteger()) { S8 type = (U8)sd[w].asInteger(); mInventoryType = static_cast<LLInventoryType::EType>(type); } } w = INV_FLAGS_LABEL; if (sd.has(w)) { if (sd[w].isBinary()) { mFlags = ll_U32_from_sd(sd[w]); } else if(sd[w].isInteger()) { mFlags = sd[w].asInteger(); } //<singu> // Define a few magic constants that are not accessible otherwise, from here. // mInventoryType: static U32 IT_WEARABLE = 18; // LLInventoryType::IT_WEARABLE // mType, these are the two asset types that are IT_WEARABLE: static U32 AT_BODYPART = 13; // LLAssetType::AT_BODYPART // Viewer local values: static U32 WT_UNKNOWN = 16; // LLWearableType::WT_UNKNOWN static U32 WT_COUNT = 17; // LLWearableType::WT_COUNT // The last 8 bits of mFlags contain the wearable type. static U32 II_FLAGS_WEARABLES_MASK = 0xff; // LLInventoryItemFlags::II_FLAGS_WEARABLES_MASK // The wearable type is stored in the lower 8 bits of mFlags. U32 wt = mFlags & II_FLAGS_WEARABLES_MASK; // Because WT_UNKNOWN now has locally a special meaning, make sure we don't receive it from the server. if (wt == WT_UNKNOWN) { LL_DEBUGS() << "Received inventory item with wearable type WT_UNKNOWN from server!" << LL_ENDL; // Change this new wearable type to WT_COUNT, as if when we had not inserted WT_UNKNOWN locally. mFlags += 1; wt = WT_COUNT; } // Detect possible problematic items. if (wt == 0 && mInventoryType == IT_WEARABLE && mType != AT_BODYPART) { // This is not possible, and therefore is probably an item creatd by a pre-multiwear viewer (or Second Inventory, etc). // The wearable type is NOT a shape (0) in that case of course, but we don't know what it is without downloading the // asset. mFlags |= WT_UNKNOWN; } //</singu> } w = INV_NAME_LABEL; if (sd.has(w)) { mName = sd[w].asString(); LLStringUtil::replaceNonstandardASCII(mName, ' '); LLStringUtil::replaceChar(mName, '|', ' '); } w = INV_DESC_LABEL; if (sd.has(w)) { mDescription = sd[w].asString(); LLStringUtil::replaceNonstandardASCII(mDescription, ' '); } w = INV_CREATION_DATE_LABEL; if (sd.has(w)) { mCreationDate = sd[w].asInteger(); } // Need to convert 1.0 simstate files to a useful inventory type // and potentially deal with bad inventory tyes eg, a landmark // marked as a texture. if((LLInventoryType::IT_NONE == mInventoryType) || !inventory_and_asset_types_match(mInventoryType, mType)) { LL_DEBUGS() << "Resetting inventory type for " << mUUID << LL_ENDL; mInventoryType = LLInventoryType::defaultForAssetType(mType); } mPermissions.initMasks(mInventoryType); return true; fail: return false; }