void FSWSAssetBlacklist::addNewItemToBlacklistData(const LLUUID& id, const LLSD& data, bool save) { LLAssetType::EType type = S32toAssetType(data["asset_type"].asInteger()); addEntryToBlacklistMap(id, type); mBlacklistData[id] = data; if (type == LLAssetType::AT_SOUND) { gVFS->removeFile(id, LLAssetType::AT_SOUND); std::string wav_path = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, id.asString()) + ".dsf"; if (gDirUtilp->fileExists(wav_path)) { LLFile::remove(wav_path); } gAudiop->removeAudioData(id); } if (save) { saveBlacklist(); } FSFloaterWSAssetBlacklist* floater = LLFloaterReg::getTypedInstance<FSFloaterWSAssetBlacklist>("ws_asset_blacklist"); if (floater) { floater->addElementToList(id, data); } }
void FSWSAssetBlacklist::addNewItemToBlacklistData(LLUUID id, LLSD data, bool save) { LLAssetType::EType type = S32toAssetType(data["asset_type"].asInteger()); addEntryToBlacklistMap(id,type); BlacklistData.insert(std::pair<LLUUID,LLSD>(id,data)); if (save) { saveBlacklist(); } FSFloaterWSAssetBlacklist* floater = LLFloaterReg::getTypedInstance<FSFloaterWSAssetBlacklist>("ws_asset_blacklist"); if (floater) { floater->addElementToList(id, data); } }
void FSWSAssetBlacklist::removeItemFromBlacklist(const LLUUID& id) { blacklist_data_t::iterator it; it = mBlacklistData.find(id); if (it == mBlacklistData.end()) { return; } LLSD data = it->second; LLAssetType::EType type = S32toAssetType(data["asset_type"].asInteger()); mBlacklistTypeContainer[type].erase(id); mBlacklistData.erase(it); saveBlacklist(); }
void FSWSAssetBlacklist::removeItemFromBlacklist(LLUUID id) { std::map<LLUUID,LLSD>::iterator it; it = BlacklistData.find(id); if (it == BlacklistData.end()) { return; } LLSD data = it->second; BlacklistIDs[S32toAssetType(data["asset_type"].asInteger())].erase( std::remove(BlacklistIDs[S32toAssetType(data["asset_type"].asInteger())].begin(), BlacklistIDs[S32toAssetType(data["asset_type"].asInteger())].end(), id), BlacklistIDs[S32toAssetType(data["asset_type"].asInteger())].end()); BlacklistData.erase(id); saveBlacklist(); }
void FSWSAssetBlacklist::loadBlacklist() { if (gDirUtilp->fileExists(mBlacklistFileName)) { llifstream blacklist_data_stream(mBlacklistFileName); if (blacklist_data_stream.is_open()) { LLSD data; if (LLSDSerialize::fromXML(data, blacklist_data_stream) >= 1) { for (LLSD::map_const_iterator itr = data.beginMap(); itr != data.endMap(); ++itr) { LLUUID uid = LLUUID(itr->first); LLXORCipher cipher(MAGIC_ID.mData, UUID_BYTES); cipher.decrypt(uid.mData, UUID_BYTES); LLSD data = itr->second; if (uid.isNull()) { continue; } LLAssetType::EType type = S32toAssetType(data["asset_type"].asInteger()); if (type == LLAssetType::AT_NONE) { continue; } addNewItemToBlacklistData(uid, data, false); } } } blacklist_data_stream.close(); } else { // Try to import old blacklist data from Phoenix std::string old_file = gDirUtilp->getOSUserDir() + gDirUtilp->getDirDelimiter() + "SecondLife" + gDirUtilp->getDirDelimiter() + "user_settings" + gDirUtilp->getDirDelimiter() + "floater_blist_settings.xml"; if (gDirUtilp->fileExists(old_file)) { LLSD datallsd; llifstream oldfile; oldfile.open(old_file.c_str()); if (oldfile.is_open()) { LLSDSerialize::fromXMLDocument(datallsd, oldfile); for (LLSD::map_const_iterator itr = datallsd.beginMap(); itr != datallsd.endMap(); ++itr) { LLUUID uid = LLUUID(itr->first); LLSD data = itr->second; if (uid.isNull() || !data.has("entry_name") || !data.has("entry_type") || !data.has("entry_date")) { continue; } LLAssetType::EType type = S32toAssetType(data["entry_type"].asInteger()); LLSD newdata; newdata["asset_name"] = "[PHOENIX] " + data["entry_name"].asString(); newdata["asset_type"] = type; newdata["asset_date"] = data["entry_date"].asString(); //if (!data["ID_hashed"].asBoolean()) //{ // uid = LLUUID::generateNewID(uid.asString() + "hash"); //} addNewItemToBlacklistData(uid, newdata, false); } } oldfile.close(); saveBlacklist(); llinfos << "Using old Phoenix file: " << old_file << llendl; } else { llinfos << "No Settings file found." << old_file << llendl; } } }