void LLPanelFriends::filterContacts() { std::string friend_name; std::string search_name; search_name = LLPanelFriends::getChild<LLLineEditor>("buddy_search_lineedit")->getValue().asString(); if ((search_name != "" /*&& search_name != mLastContactSearch*/)) { mLastContactSearch = search_name; refreshNames(LLFriendObserver::ADD); std::vector<LLScrollListItem*> vFriends = mFriendsList->getAllData(); // all of it. for (std::vector<LLScrollListItem*>::iterator itr = vFriends.begin(); itr != vFriends.end(); ++itr) { friend_name = utf8str_tolower((*itr)->getColumn(LIST_FRIEND_NAME)->getValue().asString()); BOOL show_entry = (friend_name.find(utf8str_tolower(search_name)) != std::string::npos); if (!show_entry) { mFriendsList->deleteItems((*itr)->getValue()); } } refreshUI(); } else if (search_name == "" && search_name != mLastContactSearch) refreshNames(LLFriendObserver::ADD); }
S32 LLTextParser::findPattern(const std::string &text, LLSD highlight) { if (!highlight.has("pattern")) return -1; std::string pattern=std::string(highlight["pattern"]); std::string ltext=text; if (!(bool)highlight["case_sensitive"]) { ltext = utf8str_tolower(text); pattern= utf8str_tolower(pattern); } size_t found=std::string::npos; switch ((S32)highlight["condition"]) { case CONTAINS: found = ltext.find(pattern); break; case MATCHES: found = (! ltext.compare(pattern) ? 0 : std::string::npos); break; case STARTS_WITH: found = (! ltext.find(pattern) ? 0 : std::string::npos); break; case ENDS_WITH: S32 pos = ltext.rfind(pattern); if (pos >= 0 && (ltext.length()-pattern.length()==pos)) found = pos; break; } return found; }
void LLPanelFriends::filterContacts(const std::string& search_name) { std::string friend_name; if ((search_name != "" /*&& search_name != mLastContactSearch*/)) { if (search_name.find(mLastContactSearch) == std::string::npos) { refreshNames(LLFriendObserver::ADD); } //llinfos << "search_name = " << search_name <<llendl; std::vector<LLScrollListItem*> vFriends = mFriendsList->getAllData(); // all of it. for (std::vector<LLScrollListItem*>::iterator itr = vFriends.begin(); itr != vFriends.end(); ++itr) { friend_name = utf8str_tolower((*itr)->getColumn(LIST_FRIEND_NAME)->getValue().asString()); BOOL show_entry = (friend_name.find(utf8str_tolower(search_name)) != std::string::npos); //llinfos << "friend_name = " << friend_name << (show_entry?" (shown)":"") <<llendl; if (!show_entry) { mFriendsList->deleteItems((*itr)->getValue()); } } mFriendsList->updateLayout(); refreshUI(); } else if (search_name == "" && search_name != mLastContactSearch) refreshNames(LLFriendObserver::ADD); mLastContactSearch = search_name; }
bool SHCommandHandler::handleCommand(bool from_chat, const std::string &full_str, const LLUUID &callerid, LLViewerObject *pCaller) { static const LLCachedControl<bool> sh_allow_script_commands("SHAllowScriptCommands",true); //Are script commands enabled? static const LLCachedControl<bool> sh_allow_chat_commands("AscentCmdLine",true); //Are chat commands enabled? static const LLCachedControl<std::string> sh_script_cmd_prefix("SHScriptCommandPrefix","#@#@!");//Incomming script commands are prefixed with this string. static const LLCachedControl<std::string> sh_chat_cmd_prefix("SHChatCommandPrefix",">>"); //Outgoing chat commands are prefixed with this string. static const LLCachedControl<std::string> sh_script_cmd_sep("SHScriptCommandSeparator","|"); //Separator for script commands static const LLCachedControl<std::string> sh_chat_cmd_sep("SHChatCommandSeparator"," "); //Separator for chat commands const char *szPrefix = from_chat ? sh_chat_cmd_prefix.get().c_str() : sh_script_cmd_prefix.get().c_str(); const size_t prefix_len = strlen(szPrefix); if(full_str.length() <= prefix_len || (prefix_len && full_str.substr(0,prefix_len)!=szPrefix)) return false; //Not a command else if(!isalnum(full_str.c_str()[prefix_len])) return false; //Commands must start with a # or letter else if((!from_chat && !sh_allow_script_commands) || (from_chat && !sh_allow_chat_commands)) return !!prefix_len; //These commands are disabled. const std::string trimmed_str = full_str.substr(prefix_len,std::string::npos); typedef boost::char_separator<char> sep_t; const sep_t sep(from_chat ? sh_chat_cmd_sep.get().c_str(): sh_script_cmd_sep.get().c_str(),"", boost::keep_empty_tokens); const boost::tokenizer<sep_t> tokens(trimmed_str, sep); const boost::tokenizer<sep_t>::const_iterator tok_end = tokens.end(); boost::tokenizer<sep_t>::const_iterator tok_iter = tokens.begin(); if(tok_iter == tok_end) //Shouldn't ever be true. return !from_chat && !!prefix_len; //Don't spam if the prefix was correct yet the string was empty. LLSD cmd_args; //Push tokens into LLSD so args can be looked up via args[#] bool found = false; //Return this if found. Also used to determine if cmd_args has been set up. //Now look for the command. std::list<SHCommandHandler*> &CommandList = from_chat ? getChatCommandList() : getScriptCommandList(); std::list<SHCommandHandler*>::iterator cmd_iter = CommandList.begin(); const std::list<SHCommandHandler*>::iterator cmd_end = CommandList.end(); const std::string search_arg = utf8str_tolower(*tok_iter); for(cmd_iter;cmd_iter!=cmd_end;++cmd_iter) { if(search_arg==utf8str_tolower((*cmd_iter)->getName())) { if(!found) { found = true; int i = -1; for(tok_iter;tok_iter!=tok_end;++tok_iter) //Fill the LLSD cmd_args[++i] = (*tok_iter); } (*cmd_iter)->Dispatch(cmd_args,trimmed_str,callerid,pCaller); } } return found || !!prefix_len; //Don't spam if the prefix was correct yet the command wasn't found. }
// Apart from well-known cases, in general this function returns the domain of the loginUri (with the "login." stripped off). // This should be correct for all SL BETA grids, assuming they have the form of "login.<gridId>.lindenlab.com", in which // case it returns "<gridId>.lindenlab.com". // // Well-known cases that deviate from this: // agni --> "secondlife.com" // damballah --> "secondlife-staging.com" // static std::string getMarketplaceDomain() { std::string domain; if (gHippoGridManager->getCurrentGrid()->isSecondLife()) { if (gHippoGridManager->getConnectedGrid()->isInProductionGrid()) { domain = "secondlife.com"; // agni } else { // SecondLife(tm) BETA grid. // Using the login URI is a bit of a kludge, but it's the best we've got at the moment. domain = utf8str_tolower(getLoginUriDomain()); // <gridid>.lindenlab.com; ie, "aditi.lindenlab.com". llassert(domain.length() > 14 && domain.substr(domain.length() - 14) == ".lindenlab.com"); if (domain == "damballah.lindenlab.com") { domain = "secondlife-staging.com"; } } } else { // TODO: Find out if OpenSim, and Avination adopted any outbox stuffs, if so code HippoGridManager for this // Aurora grid has not. // For now, set domain on other grids to the loginUri domain, so we don't harass LL web services. domain = getLoginUriDomain(); //gHippoGridManager->getCurrentGrid()->getMarketPlaceDomain(); } return domain; }
void HippoGridInfo::setLoginUri(const std::string& loginUri) { std::string uri = loginUri; mLoginUri = sanitizeUri(uri); if (utf8str_tolower(LLURI(uri).hostName()) == "login.agni.lindenlab.com") { mIsInProductionGrid = true; } }
bool LLGridManager::addGrid(LLSD& grid_data) { if (grid_data.isMap() && grid_data.has(GRID_VALUE)) { std::string grid = utf8str_tolower(grid_data[GRID_VALUE]); // grid should be in the form of a dns address if (!grid.empty() && grid.find_first_not_of("abcdefghijklmnopqrstuvwxyz1234567890-_. ") != std::string::npos) { llinfos << "Invalid grid name " << grid << llendl; return false; } // populate the other values if they don't exist if (!grid_data.has(GRID_LABEL_VALUE)) { grid_data[GRID_LABEL_VALUE] = grid; } if (!grid_data.has(GRID_ID_VALUE)) { grid_data[GRID_ID_VALUE] = grid; } // if the grid data doesn't include any of the URIs, then // generate them from the grid, which should be a dns address if (!grid_data.has(GRID_LOGIN_URI_VALUE)) { grid_data[GRID_LOGIN_URI_VALUE] = LLSD::emptyArray(); grid_data[GRID_LOGIN_URI_VALUE].append(std::string("https://") + grid + "/cgi-bin/login.cgi"); } // Populate to the default values if (!grid_data.has(GRID_LOGIN_PAGE_VALUE)) { grid_data[GRID_LOGIN_PAGE_VALUE] = std::string("http://") + grid + "/app/login/"; } if (!grid_data.has(GRID_HELPER_URI_VALUE)) { grid_data[GRID_HELPER_URI_VALUE] = std::string("https://") + grid + "/helpers/"; } if (!grid_data.has(GRID_LOGIN_IDENTIFIER_TYPES)) { // non system grids and grids that haven't already been configured with values // get both types of credentials. grid_data[GRID_LOGIN_IDENTIFIER_TYPES] = LLSD::emptyArray(); grid_data[GRID_LOGIN_IDENTIFIER_TYPES].append(CRED_IDENTIFIER_TYPE_AGENT); grid_data[GRID_LOGIN_IDENTIFIER_TYPES].append(CRED_IDENTIFIER_TYPE_ACCOUNT); } LL_DEBUGS("GridManager") << "ADDING: " << grid << LL_ENDL; mGridList[grid] = grid_data; } return true; }
//static std::string LLWeb::expandURLSubstitutions(const std::string &url, const LLSD &default_subs) { LLSD substitution = default_subs; substitution["VERSION"] = LLVersionInfo::getVersion(); substitution["VERSION_MAJOR"] = LLVersionInfo::getMajor(); substitution["VERSION_MINOR"] = LLVersionInfo::getMinor(); substitution["VERSION_PATCH"] = LLVersionInfo::getPatch(); substitution["VERSION_BUILD"] = LLVersionInfo::getBuild(); substitution["CHANNEL"] = LLVersionInfo::getChannel(); // substitution["GRID"] = LLGridManager::getInstance()->getGridLabel(); // substitution["GRID_LOWERCASE"] = utf8str_tolower(LLGridManager::getInstance()->getGridLabel()); //NOTE: getGridLabel() returns e.g. "Second Life" // getGridNick() returns e.g. "agni" substitution["GRID"] = LLGridManager::getInstance()->getGridNick(); substitution["GRID_LOWERCASE"] = utf8str_tolower(LLGridManager::getInstance()->getGridNick()); substitution["OS"] = LLAppViewer::instance()->getOSInfo().getOSStringSimple(); substitution["SESSION_ID"] = gAgent.getSessionID(); substitution["FIRST_LOGIN"] = gAgent.isFirstLogin(); // work out the current language std::string lang = LLUI::getLanguage(); if (lang == "en-us") { // *HACK: the correct fix is to change English.lproj/language.txt, // but we're late in the release cycle and this is a less risky fix lang = "en"; } substitution["LANGUAGE"] = lang; // find the region ID LLUUID region_id; LLViewerRegion *region = gAgent.getRegion(); if (region) { region_id = region->getRegionID(); } substitution["REGION_ID"] = region_id; // find the parcel local ID S32 parcel_id = 0; LLParcel* parcel = LLViewerParcelMgr::getInstance()->getAgentParcel(); if (parcel) { parcel_id = parcel->getLocalID(); } substitution["PARCEL_ID"] = llformat("%d", parcel_id); // expand all of the substitution strings and escape the url std::string expanded_url = url; LLStringUtil::format(expanded_url, substitution); return LLWeb::escapeURL(expanded_url); }
void HippoGridInfo::setLoginUri(const std::string& loginUri) { mLoginUri = sanitizeUri(loginUri); if (utf8str_tolower(LLURI(mLoginUri).hostName()) == "login.agni.lindenlab.com") { mIsInProductionGrid = true; useHttps(); setPlatform(PLATFORM_SECONDLIFE); } else if (utf8str_tolower(LLURI(mLoginUri).hostName()) == "login.aditi.lindenlab.com") { useHttps(); setPlatform(PLATFORM_SECONDLIFE); } else if (utf8str_tolower(LLURI(mLoginUri).hostName()) == "login.avination.com" || utf8str_tolower(LLURI(mLoginUri).hostName()) == "login.avination.net") { mIsInAvination = true; useHttps(); } }
U8 *LLGesture::deserialize(U8 *buffer, S32 max_size) { U8 *tmp = buffer; if (tmp + sizeof(mKey) + sizeof(mMask) + 16 > buffer + max_size) { llwarns << "Attempt to read past end of buffer, bad data!!!!" << llendl; return buffer; } htonmemcpy(&mKey, tmp, MVT_S8, 1); tmp += sizeof(mKey); htonmemcpy(&mMask, tmp, MVT_U32, 4); tmp += sizeof(mMask); htonmemcpy(mSoundItemID.mData, tmp, MVT_LLUUID, 16); tmp += 16; mTrigger.assign((char *)tmp); mTriggerLower = mTrigger; mTriggerLower = utf8str_tolower(mTriggerLower); tmp += mTrigger.length() + 1; mAnimation.assign((char *)tmp); //RN: force animation names to lower case // must do this for backwards compatibility mAnimation = utf8str_tolower(mAnimation); tmp += mAnimation.length() + 1; mOutputString.assign((char *)tmp); tmp += mOutputString.length() + 1; if (tmp > buffer + max_size) { llwarns << "Read past end of buffer, bad data!!!!" << llendl; return tmp; } return tmp; }
LLGesture::LLGesture(KEY key, MASK mask, const std::string &trigger, const LLUUID &sound_item_id, const std::string &animation, const std::string &output_string) : mKey(key), mMask(mask), mTrigger(trigger), mTriggerLower(trigger), mSoundItemID(sound_item_id), mAnimation(animation), mOutputString(output_string) { mTriggerLower = utf8str_tolower(mTriggerLower); }
static std::string getMarketplaceDomain() { std::string domain = "secondlife.com"; if (!LLGridManager::getInstance()->isInSLMain()) { const std::string& grid_label = LLGridManager::getInstance()->getGridLabel(); const std::string& grid_label_lower = utf8str_tolower(grid_label); if (grid_label_lower == "damballah") { domain = "secondlife-staging.com"; } else { domain = llformat("%s.lindenlab.com", grid_label_lower.c_str()); } } return domain; }
bool LLGridManager::addGrid(LLSD& grid_data) { bool added = false; if (grid_data.isMap() && grid_data.has(GRID_VALUE)) { std::string grid = utf8str_tolower(grid_data[GRID_VALUE].asString()); if ( getGrid(grid_data[GRID_VALUE]).empty() && getGrid(grid).empty() ) { std::string grid_id = grid_data.has(GRID_ID_VALUE) ? grid_data[GRID_ID_VALUE].asString() : ""; if ( getGrid(grid_id).empty() ) { // populate the other values if they don't exist if (!grid_data.has(GRID_LABEL_VALUE)) { grid_data[GRID_LABEL_VALUE] = grid; } if (!grid_data.has(GRID_ID_VALUE)) { grid_data[GRID_ID_VALUE] = grid; } // if the grid data doesn't include any of the URIs, then // generate them from the grid, which should be a dns address if (!grid_data.has(GRID_LOGIN_URI_VALUE)) { grid_data[GRID_LOGIN_URI_VALUE] = LLSD::emptyArray(); grid_data[GRID_LOGIN_URI_VALUE].append(std::string("https://") + grid + "/cgi-bin/login.cgi"); } // Populate to the default values if (!grid_data.has(GRID_LOGIN_PAGE_VALUE)) { grid_data[GRID_LOGIN_PAGE_VALUE] = std::string("http://") + grid + "/app/login/"; } if (!grid_data.has(GRID_HELPER_URI_VALUE)) { grid_data[GRID_HELPER_URI_VALUE] = std::string("https://") + grid + "/helpers/"; } if (!grid_data.has(GRID_LOGIN_IDENTIFIER_TYPES)) { // non system grids and grids that haven't already been configured with values // get both types of credentials. grid_data[GRID_LOGIN_IDENTIFIER_TYPES] = LLSD::emptyArray(); grid_data[GRID_LOGIN_IDENTIFIER_TYPES].append(CRED_IDENTIFIER_TYPE_AGENT); grid_data[GRID_LOGIN_IDENTIFIER_TYPES].append(CRED_IDENTIFIER_TYPE_ACCOUNT); } LL_DEBUGS("GridManager") <<grid<<"\n" <<" id: "<<grid_data[GRID_ID_VALUE].asString()<<"\n" <<" label: "<<grid_data[GRID_LABEL_VALUE].asString()<<"\n" <<" login page: "<<grid_data[GRID_LOGIN_PAGE_VALUE].asString()<<"\n" <<" helper page: "<<grid_data[GRID_HELPER_URI_VALUE].asString()<<"\n"; /* still in LL_DEBUGS */ for (LLSD::array_const_iterator login_uris = grid_data[GRID_LOGIN_URI_VALUE].beginArray(); login_uris != grid_data[GRID_LOGIN_URI_VALUE].endArray(); login_uris++) { LL_CONT << " login uri: "<<login_uris->asString()<<"\n"; } LL_CONT << LL_ENDL; mGridList[grid] = grid_data; added = true; } else { LL_WARNS("GridManager")<<"duplicate grid id'"<<grid_id<<"' ignored"<<LL_ENDL; } } else { LL_WARNS("GridManager")<<"duplicate grid name '"<<grid<<"' ignored"<<LL_ENDL; } } else { LL_WARNS("GridManager")<<"invalid grid definition ignored"<<LL_ENDL; } return added; }
static size_t headerCallback(void* data, size_t size, size_t nmemb, void* user) { const char* header_line = (const char*)data; size_t header_len = size * nmemb; LLURLRequestComplete* complete = (LLURLRequestComplete*)user; if (!complete || !header_line) { return header_len; } // *TODO: This should be a utility in llstring.h: isascii() for (size_t i = 0; i < header_len; ++i) { if (header_line[i] < 0) { return header_len; } } std::string header(header_line, header_len); // Per HTTP spec the first header line must be the status line. if (!complete->haveHTTPStatus()) { if (header.substr(0,5) == "HTTP/") { std::string::iterator end = header.end(); std::string::iterator pos1 = std::find(header.begin(), end, ' '); if (pos1 != end) ++pos1; std::string::iterator pos2 = std::find(pos1, end, ' '); if (pos2 != end) ++pos2; std::string::iterator pos3 = std::find(pos2, end, '\r'); std::string version(header.begin(), pos1); std::string status(pos1, pos2); std::string reason(pos2, pos3); int statusCode = atoi(status.c_str()); if (statusCode >= 300 && statusCode < 400) { // This is a redirect, ignore it and all headers // until we find a normal status code. } else if (statusCode > 0) { complete->httpStatus((U32)statusCode, reason); } } return header_len; } std::string::iterator sep = std::find(header.begin(),header.end(),':'); if (sep != header.end()) { std::string key(header.begin(), sep); std::string value(sep + 1, header.end()); key = utf8str_tolower(utf8str_trim(key)); value = utf8str_trim(value); complete->header(key, value); } else { LLStringUtil::trim(header); if (!header.empty()) { llwarns << "Unable to parse header: " << header << llendl; } } return header_len; }
void ASFloaterUploadBrowser::refresh() { std::string filename; std::string fullPath = mPathName + gDirUtilp->getDirDelimiter(); mFileList->deselectAllItems(); mFileList->deleteAllItems(); childSetValue("dir_path", gDirUtilp->getDirName(fullPath)); mUploaderSettings["ActivePath"] = mPathName; gSavedSettings.setLLSD("AscentUploadSettings", mUploaderSettings); gDirUtilp->getNextFileInDir(gDirUtilp->getChatLogsDir(),"*", filename, false); //Clears the last file bool found = true; S32 file_count = 0; while(found) { found = gDirUtilp->getNextFileInDir(fullPath, "*.*", filename, false); if(found) { S32 periodIndex = filename.find_last_of("."); std::string extension = filename.substr(periodIndex + 1, filename.length() - 1); std::string extensionL = utf8str_tolower(extension); LLSD element; element["path"] = mPathName + filename; LLSD& filename_column = element["columns"][LIST_FILE_NAME]; filename_column["column"] = "file_name"; filename_column["font"] = "SANSSERIF"; filename_column["font-style"] = "NORMAL"; LLSD& filetype_column = element["columns"][LIST_FILE_TYPE]; filetype_column["column"] = "file_type"; filetype_column["type"] = "number"; LLSD& assettype_column = element["columns"][LIST_ASSET_TYPE]; assettype_column["column"] = "asset_type"; assettype_column["type"] = "number"; LLSD& invtype_column = element["columns"][LIST_INVENTORY_TYPE]; invtype_column["column"] = "icon_inventory_type"; invtype_column["type"] = "icon"; invtype_column["value"] = "inv_folder_trash.tga"; if (((extensionL == "jpeg")||(extensionL == "jpg")||(extensionL == "tga") ||(extensionL == "png")||(extensionL == "bmp"))&&((mFilterType == "None")||(mFilterType == "Texture"))) { invtype_column["value"] = "inv_item_texture.tga"; filename_column["value"] = filename.substr(0, periodIndex); filetype_column["value"] = FILE_TEXTURE; assettype_column["value"] = LIST_TYPE_FILE; } else if ((extensionL == "wav")&&((mFilterType == "None")||(mFilterType == "Sound"))) { invtype_column["value"] = "inv_item_sound.tga"; filename_column["value"] = filename.substr(0, periodIndex); filetype_column["value"] = FILE_SOUND; assettype_column["value"] = LIST_TYPE_FILE; } else if (((extensionL == "bvh")||(extensionL == "anim"))&&((mFilterType == "None")||(mFilterType == "Animation"))) { invtype_column["value"] = "inv_item_animation.tga"; filename_column["value"] = filename.substr(0, periodIndex); filetype_column["value"] = FILE_ANIMATION; assettype_column["value"] = LIST_TYPE_FILE; } else if ((extension == filename.substr(0, filename.length() - 1))&&(filename != ".")) { std::string test_path = mPathName + gDirUtilp->getDirDelimiter() + filename + gDirUtilp->getDirDelimiter(); S32 file_count = gDirUtilp->countFilesInDir(test_path, "*.*"); if(file_count) { invtype_column["value"] = "inv_folder_plain_closed.tga"; filename_column["value"] = filename; filetype_column["value"] = FOLDER; assettype_column["value"] = LIST_TYPE_FOLDER; } } else if (filename == "..") { invtype_column["value"] = "inv_folder_plain_open.tga"; filename_column["value"] = filename; filetype_column["value"] = FOLDER; assettype_column["value"] = LIST_TYPE_PARENT; } if (invtype_column["value"].asString() != "inv_folder_trash.tga") { mFileList->addElement(element, ADD_BOTTOM); if (assettype_column["value"].asInteger() == LIST_TYPE_FILE) { file_count++; } } } } std::string result; LLResMgr::getInstance()->getIntegerString(result, file_count); if (result == "") result = "0"; childSetTextArg("result_label", "[COUNT]", result); mFileList->sortItems(); llinfos << "Total files loaded: " << result << "." << llendl; }
// // LLGridManager::addGrid - add a grid to the grid list, populating the needed values // if they're not populated yet. // void LLGridManager::addGrid(GridEntry* grid_entry, AddState state) { if(!grid_entry) { llwarns << "addGrid called with NULL grid_entry. Please send a bug report." << llendl; state = FAIL; } if(!grid_entry->grid.has(GRID_VALUE)) { state = FAIL; } else if(grid_entry->grid[GRID_VALUE].asString().empty()) { state = FAIL; } else if(!grid_entry->grid.isMap()) { state = FAIL; } if ((FETCH == state) ||(FETCHTEMP == state) || (SYSTEM == state)) { std::string grid = utf8str_tolower(grid_entry->grid[GRID_VALUE]); // grid should be in the form of a dns address // but also support localhost:9000 or localhost:9000/login if ( !grid.empty() && grid.find_first_not_of("abcdefghijklmnopqrstuvwxyz1234567890-_.:/@% ") != std::string::npos) { printf("grid name: %s", grid.c_str()); if (grid_entry) { state = FAIL; delete grid_entry; grid_entry = NULL; } throw LLInvalidGridName(grid); } size_t find_last_slash = grid.find_last_of("/"); if ( (grid.length()-1) == find_last_slash ) { grid.erase(find_last_slash); grid_entry->grid[GRID_VALUE] = grid; } if (FETCHTEMP == state) { grid_entry->grid["FLAG_TEMPORARY"] = "TRUE"; state = FETCH; } } if ((FETCH == state) || (RETRY == state)) { std::string grid = utf8str_tolower(grid_entry->grid[GRID_VALUE]); std::string match = "://"; size_t find_scheme = grid.find(match); if ( std::string::npos != find_scheme) { // We only support http so just remove anything the user might have chosen grid.erase(0,find_scheme+match.length()); grid_entry->grid[GRID_VALUE] = grid; } std::string uri = "http://"+grid; if (std::string::npos != uri.find("lindenlab.com")) { state = SYSTEM; } else { if ( std::string::npos == uri.find(".") || std::string::npos != uri.find("127.0.0.1") || std::string::npos != uri.find("localhost") ) { state = LOCAL; } grid_entry->grid[GRID_LOGIN_URI_VALUE] = LLSD::emptyArray(); grid_entry->grid[GRID_LOGIN_URI_VALUE].append(uri); size_t find_last_slash = uri.find_last_of("/"); if ( (uri.length()-1) != find_last_slash ) { uri.append("/"); } uri.append("get_grid_info"); LL_DEBUGS("GridManager") << "get_grid_info uri: " << uri << LL_ENDL; time_t last_modified = 0; if(grid_entry->grid.has("LastModified")) { LLDate saved_value = grid_entry->grid["LastModified"]; last_modified = (time_t)saved_value.secondsSinceEpoch(); } LLHTTPClient::getIfModified(uri, new GridInfoRequestResponder(this, grid_entry, state), last_modified); return; } } if(TRYLEGACY == state) { std::string grid = utf8str_tolower(grid_entry->grid[GRID_VALUE]); std::string uri = "https://" + grid + "/cgi-bin/login.cgi"; llwarns << "No gridinfo found. Trying if legacy login page exists: " << uri << llendl; LLHTTPClient::get(uri, new GridInfoRequestResponder(this, grid_entry, state)); return; } if(FAIL != state) { std::string grid = utf8str_tolower(grid_entry->grid[GRID_VALUE]); // populate the other values if they don't exist if (!grid_entry->grid.has(GRID_LABEL_VALUE)) { grid_entry->grid[GRID_LABEL_VALUE] = grid; llwarns << "No \"gridname\" found in grid info, setting to " << grid_entry->grid[GRID_LABEL_VALUE].asString() << llendl; } if (!grid_entry->grid.has(GRID_NICK_VALUE)) { grid_entry->grid[GRID_NICK_VALUE] = grid; llwarns << "No \"gridnick\" found in grid info, setting to " << grid_entry->grid[GRID_NICK_VALUE].asString() << llendl; } } if (SYSTEM == state) { std::string grid = utf8str_tolower(grid_entry->grid[GRID_VALUE]); // if the grid data doesn't include any of the URIs, then // generate them from the grid if (!grid_entry->grid.has(GRID_LOGIN_URI_VALUE)) { grid_entry->grid[GRID_LOGIN_URI_VALUE] = LLSD::emptyArray(); grid_entry->grid[GRID_LOGIN_URI_VALUE].append(std::string("https://") + grid + "/cgi-bin/login.cgi"); llwarns << "Adding Legacy Login Service at:" << grid_entry->grid[GRID_LOGIN_URI_VALUE].asString() << llendl; } // Populate to the default values if (!grid_entry->grid.has(GRID_LOGIN_PAGE_VALUE)) { grid_entry->grid[GRID_LOGIN_PAGE_VALUE] = std::string("http://") + grid + "/app/login/"; llwarns << "Adding Legacy Login Screen at:" << grid_entry->grid[GRID_LOGIN_PAGE_VALUE].asString() << llendl; } if (!grid_entry->grid.has(GRID_HELPER_URI_VALUE)) { llwarns << "Adding Legacy Economy at:" << grid_entry->grid[GRID_HELPER_URI_VALUE].asString() << llendl; grid_entry->grid[GRID_HELPER_URI_VALUE] = std::string("https://") + grid + "/helpers/"; } } if(FAIL != state) { std::string grid = utf8str_tolower(grid_entry->grid[GRID_VALUE]); if (!grid_entry->grid.has(GRID_LOGIN_IDENTIFIER_TYPES)) { // non system grids and grids that haven't already been configured with values // get both types of credentials. grid_entry->grid[GRID_LOGIN_IDENTIFIER_TYPES] = LLSD::emptyArray(); grid_entry->grid[GRID_LOGIN_IDENTIFIER_TYPES].append(CRED_IDENTIFIER_TYPE_AGENT); grid_entry->grid[GRID_LOGIN_IDENTIFIER_TYPES].append(CRED_IDENTIFIER_TYPE_ACCOUNT); } bool is_current = grid_entry->set_current; grid_entry->set_current = false; if(!grid.empty())// { if (!mGridList.has(grid)) //new grid { //finally add the grid \o/ mGridList[grid] = grid_entry->grid; ++mGridEntries; LL_DEBUGS("GridManager") << "Adding new entry: " << grid << LL_ENDL; } else { LLSD existing_grid = mGridList[grid]; if (!existing_grid.has("LastModified")) { //lack of "LastModified" means existing_grid is from fallback list, // assume its anyway older and override with the new entry mGridList[grid] = grid_entry->grid; //number of mGridEntries doesn't change LL_DEBUGS("GridManager") << "Using custom entry: " << grid << LL_ENDL; } else if (grid_entry->grid.has("LastModified")) { // (time_t)saved_value.secondsSinceEpoch(); LLDate testing_newer = grid_entry->grid["LastModified"]; LLDate existing = existing_grid["LastModified"]; LL_DEBUGS("GridManager") << "testing_newer " << testing_newer << " existing " << existing << LL_ENDL; if(testing_newer.secondsSinceEpoch() > existing.secondsSinceEpoch()) { //existing_grid is older, override. mGridList[grid] = grid_entry->grid; //number of mGridEntries doesn't change LL_DEBUGS("GridManager") << "Updating entry: " << grid << LL_ENDL; } } else { LL_DEBUGS("GridManager") << "Same or newer entry already present: " << grid << LL_ENDL; } } if(is_current) { mGrid = grid; LL_DEBUGS("GridManager") << "Selected grid is " << mGrid << LL_ENDL; setGridChoice(mGrid); } } } // This is only of use if we want to fetch infos of entire gridlists at startup /* if(grid_entry && FINISH == state || FAIL == state) { if((FINISH == state && !mCommandLineDone && 0 == mResponderCount) ||(FAIL == state && grid_entry->set_current) ) { LL_DEBUGS("GridManager") << "init CmdLineGrids" << LL_ENDL; initCmdLineGrids(); } } */ if (grid_entry) { if(!grid_entry->mOnDoneCallback.empty()) { grid_entry->mOnDoneCallback(); } delete grid_entry; grid_entry = NULL; } }