public void HandleAvatarNotesRequest(object sender, string method, List <string> args) { if (!(sender is IClientAPI)) { MainConsole.Instance.Debug("sender isn't IClientAPI"); return; } IClientAPI remoteClient = (IClientAPI)sender; IUserProfileInfo UPI = ProfileFrontend.GetUserProfile(remoteClient.AgentId); if (UPI == null) { return; } OSD notes = ""; string targetNotesUUID = args [0]; if (!UPI.Notes.TryGetValue(targetNotesUUID, out notes)) { notes = ""; } remoteClient.SendAvatarNotesReply(new UUID(targetNotesUUID), notes.AsString()); }
public LSL_Key llRequestDisplayName(LSL_Key uuid) { UUID userID = UUID.Zero; if (!UUID.TryParse(uuid, out userID)) { // => complain loudly, as specified by the LSL docs Error("llRequestDisplayName", "Failed to parse uuid for avatar."); return(UUID.Zero.ToString()); } DataserverPlugin dataserverPlugin = (DataserverPlugin)m_ScriptEngine.GetScriptPlugin("Dataserver"); UUID tid = dataserverPlugin.RegisterRequest(m_host.UUID, m_itemID, uuid.ToString()); Util.FireAndForget(delegate { string name = ""; IProfileConnector connector = Framework.Utilities.DataManager.RequestPlugin <IProfileConnector>(); if (connector != null) { IUserProfileInfo info = connector.GetUserProfile(userID); if (info != null) { name = info.DisplayName; } } dataserverPlugin.AddReply(uuid.ToString(), name, 100); }); PScriptSleep(m_sleepMsOnRequestUserName); return(tid.ToString()); }
public IUserProfileInfo GetUserProfile(UUID PrincipalID) { try { List <string> serverURIs = m_registry.RequestModuleInterface <IConfigurationService>().FindValueOf(PrincipalID.ToString(), "RemoteServerURI"); foreach (string url in serverURIs) { OSDMap map = new OSDMap(); map["Method"] = "getprofile"; map["PrincipalID"] = PrincipalID; OSDMap response = WebUtils.PostToService(url + "osd", map, true, true); if (response["_Result"].Type == OSDType.Map) { OSDMap responsemap = (OSDMap)response["_Result"]; if (responsemap.Count == 0) { continue; } IUserProfileInfo info = new IUserProfileInfo(); info.FromOSD(responsemap); return(info); } } } catch (Exception e) { MainConsole.Instance.DebugFormat("[AuroraRemoteProfileConnector]: Exception when contacting server: {0}", e); } return(null); }
/// <summary> /// Get the user's display name, currently not used? /// </summary> /// <param name = "mDhttpMethod"></param> /// <param name = "agentID"></param> /// <returns></returns> private byte[] ProcessGetDisplayName(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { //I've never seen this come in, so for now... do nothing NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query); string[] ids = query.GetValues("ids"); string username = query.GetOne("username"); OSDMap map = new OSDMap(); OSDArray agents = new OSDArray(); OSDArray bad_ids = new OSDArray(); OSDArray bad_usernames = new OSDArray(); if (ids != null) { foreach (string id in ids) { UserAccount account = m_userService.GetUserAccount(m_service.ClientCaps.AccountInfo.AllScopeIDs, UUID.Parse(id)); if (account != null) { IUserProfileInfo info = DataManager.RequestPlugin <IProfileConnector>().GetUserProfile(account.PrincipalID); if (info != null) { PackUserInfo(info, account, ref agents); } else { PackUserInfo(info, account, ref agents); } //else //Technically is right, but needs to be packed no matter what for OS based grids // bad_ids.Add (id); } } } else if (username != null) { UserAccount account = m_userService.GetUserAccount(m_service.ClientCaps.AccountInfo.AllScopeIDs, username.Replace('.', ' ')); if (account != null) { IUserProfileInfo info = DataManager.RequestPlugin <IProfileConnector>().GetUserProfile(account.PrincipalID); if (info != null) { PackUserInfo(info, account, ref agents); } else { bad_usernames.Add(username); } } } map["agents"] = agents; map["bad_ids"] = bad_ids; map["bad_usernames"] = bad_usernames; return(OSDParser.SerializeLLSDXmlBytes(map)); }
void PackUserInfo(IUserProfileInfo info, UserAccount account, ref OSDArray agents) { OSDMap agentMap = new OSDMap(); agentMap ["username"] = account.Name; agentMap ["display_name"] = (info == null || info.DisplayName == "") ? account.Name : info.DisplayName; agentMap ["legacy_first_name"] = account.FirstName; agentMap ["legacy_last_name"] = account.LastName; agentMap ["id"] = account.PrincipalID; agentMap ["is_display_name_default"] = isDefaultDisplayName(account.FirstName, account.LastName, account.Name, info == null ? account.Name : info.DisplayName); if (info != null) { if (m_update_days > 0) { agentMap ["display_name_next_update"] = OSD.FromDate(info.DisplayNameUpdated.AddDays(m_update_days)); } else { agentMap ["display_name_next_update"] = OSD.FromDate(info.DisplayNameUpdated); } } agents.Add(agentMap); }
private Hashtable MeshUploadFlagCAP(Hashtable mDhttpMethod) { OSDMap data = new OSDMap(); UserAccount acct = m_userService.GetUserAccount(UUID.Zero, m_service.AgentID); IUserProfileInfo info = m_profileConnector.GetUserProfile(m_service.AgentID); data["id"] = m_service.AgentID; data["username"] = acct.Name; data["display_name"] = info.DisplayName; data["display_name_next_update"] = Utils.UnixTimeToDateTime(0); data["legacy_first_name"] = acct.FirstName; data["legacy_last_name"] = acct.LastName; data["mesh_upload_status"] = "valid"; // add if account has ability to upload mesh? bool isDisplayNameNDefault = (info.DisplayName == acct.Name) || (info.DisplayName == acct.FirstName + "." + acct.LastName); data["is_display_name_default"] = isDisplayNameNDefault; //Send back data Hashtable responsedata = new Hashtable(); responsedata["int_response_code"] = 200; //501; //410; //404; responsedata["content_type"] = "text/plain"; responsedata["keepalive"] = false; responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(data); return(responsedata); }
/// <summary> /// Tell the client about all other display names in the region as well as send ours to all others /// </summary> /// <param name="us"></param> void OnMakeRootAgent(IScenePresence us) { if (us.IsChildAgent) { return; } IUserProfileInfo usProfile = m_profileConnector.GetUserProfile(us.UUID); //Send our name to us if (usProfile != null) { DisplayNameUpdate(usProfile.DisplayName, usProfile.DisplayName, us, us.UUID); } foreach (IScenePresence SP in us.Scene.GetScenePresences()) { if (SP.UUID != us.UUID) { IUserProfileInfo info = m_profileConnector.GetUserProfile(SP.UUID); //Send to the incoming user all known display names of avatar's around the client if (info != null) { DisplayNameUpdate(info.DisplayName, info.DisplayName, SP, us.UUID); } if (usProfile != null) { DisplayNameUpdate(usProfile.DisplayName, usProfile.DisplayName, us, SP.UUID); } } } }
/// <summary> /// Update a user's profile (Note: this does not work if the user does not have a profile) /// </summary> /// <param name="Profile"></param> /// <returns></returns> public bool UpdateUserProfile(IUserProfileInfo Profile) { IUserProfileInfo previousProfile = GetUserProfile(Profile.PrincipalID); //Make sure the previous one exists if (previousProfile == null) { return(false); } //Now fix values that the sim cannot change Profile.Partner = previousProfile.Partner; Profile.CustomType = previousProfile.CustomType; Profile.MembershipGroup = previousProfile.MembershipGroup; Profile.Created = previousProfile.Created; List <object> SetValues = new List <object>(); List <string> SetRows = new List <string>(); SetRows.Add("Value"); SetValues.Add(OSDParser.SerializeLLSDXmlString(Profile.ToOSD())); List <object> KeyValue = new List <object>(); List <string> KeyRow = new List <string>(); KeyRow.Add("ID"); KeyValue.Add(Profile.PrincipalID.ToString()); KeyRow.Add("`Key`"); KeyValue.Add("LLProfile"); //Update cache UserProfilesCache[Profile.PrincipalID] = Profile; return(GD.Update("userdata", SetValues.ToArray(), SetRows.ToArray(), KeyRow.ToArray(), KeyValue.ToArray())); }
/// <summary> /// Get a user's profile /// </summary> /// <param name="agentID"></param> /// <returns></returns> public IUserProfileInfo GetUserProfile(UUID agentID) { IUserProfileInfo UserProfile = new IUserProfileInfo(); //Try from the user profile first before getting from the DB if (UserProfilesCache.TryGetValue(agentID, out UserProfile)) { return(UserProfile); } else { UserProfile = new IUserProfileInfo(); List <string> query = null; //Grab it from the almost generic interface query = GD.Query(new string[] { "ID", "`Key`" }, new object[] { agentID, "LLProfile" }, "userdata", "Value"); if (query == null || query.Count == 0) { return(null); } //Pull out the OSDmap OSDMap profile = (OSDMap)OSDParser.DeserializeLLSDXml(query[0]); UserProfile.FromOSD(profile); //Add to the cache UserProfilesCache[agentID] = UserProfile; return(UserProfile); } }
private byte[] ProcessAvatarPickerSearch(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query); string amt = query.GetOne("page-size"); string name = query.GetOne("names"); List <UserAccount> accounts = m_service.Registry.RequestModuleInterface <IUserAccountService>().GetUserAccounts(UUID.Zero, name) ?? new List <UserAccount>(0); OSDMap body = new OSDMap(); OSDArray array = new OSDArray(); foreach (UserAccount account in accounts) { OSDMap map = new OSDMap(); map["agent_id"] = account.PrincipalID; IUserProfileInfo profileInfo = DataManager.RequestPlugin <IProfileConnector>().GetUserProfile(account.PrincipalID); map["display_name"] = (profileInfo == null || profileInfo.DisplayName == "") ? account.Name : profileInfo.DisplayName; map["username"] = account.Name; array.Add(map); } body["agents"] = array; byte[] m = OSDParser.SerializeLLSDXmlBytes(body); httpResponse.Body.Write(m, 0, m.Length); httpResponse.StatusCode = (int)System.Net.HttpStatusCode.OK; httpResponse.Send(); return(null); }
private void SendProfile(IClientAPI remoteClient, IUserProfileInfo Profile, UUID target, uint agentOnline) { UserAccount account = GetRegionUserIsIn(remoteClient.AgentId).UserAccountService.GetUserAccount(UUID.Zero, target); if (Profile == null || account == null) { return; } Byte[] charterMember; if (Profile.MembershipGroup == "") { charterMember = new Byte[1]; charterMember[0] = (Byte)((account.UserFlags & 0xf00) >> 8); } else { charterMember = OpenMetaverse.Utils.StringToBytes(Profile.MembershipGroup); } uint membershipGroupINT = 0; if (Profile.MembershipGroup != "") { membershipGroupINT = 4; } uint flags = Convert.ToUInt32(Profile.AllowPublish) + Convert.ToUInt32(Profile.MaturePublish) + membershipGroupINT + (uint)agentOnline + (uint)account.UserFlags; remoteClient.SendAvatarInterestsReply(target, Convert.ToUInt32(Profile.Interests.WantToMask), Profile.Interests.WantToText, Convert.ToUInt32(Profile.Interests.CanDoMask), Profile.Interests.CanDoText, Profile.Interests.Languages); remoteClient.SendAvatarProperties(account.PrincipalID, Profile.AboutText, Util.ToDateTime(account.Created).ToString("M/d/yyyy", CultureInfo.InvariantCulture), charterMember, Profile.FirstLifeAboutText, flags, Profile.FirstLifeImage, Profile.Image, Profile.WebURL, new UUID(Profile.Partner)); }
public void UpdateAvatarProperties(IClientAPI remoteClient, string AboutText, string FLAboutText, UUID FLImageID, UUID ImageID, string WebProfileURL, bool allowpublish, bool maturepublish) { IUserProfileInfo UPI = ProfileFrontend.GetUserProfile(remoteClient.AgentId); if (UPI == null) { return; } if (UPI.Image != ImageID || UPI.FirstLifeImage != FLImageID || UPI.AboutText != AboutText || UPI.FirstLifeAboutText != FLAboutText || UPI.WebURL != WebProfileURL || UPI.AllowPublish != allowpublish || UPI.MaturePublish != maturepublish) { UPI.Image = ImageID; UPI.FirstLifeImage = FLImageID; UPI.AboutText = AboutText; UPI.FirstLifeAboutText = FLAboutText; UPI.WebURL = WebProfileURL; UPI.AllowPublish = allowpublish; UPI.MaturePublish = maturepublish; ProfileFrontend.UpdateUserProfile(UPI); } SendProfile(remoteClient, UPI, remoteClient.Scene.UserAccountService.GetUserAccount(remoteClient.AllScopeIDs, remoteClient.AgentId), 16); }
public void RequestAvatarProperty(IClientAPI remoteClient, UUID target) { IUserProfileInfo UPI = ProfileFrontend.GetUserProfile(target); UserAccount targetAccount = remoteClient.Scene.UserAccountService.GetUserAccount(remoteClient.AllScopeIDs, target); if (UPI == null || !targetAccount.Valid) { remoteClient.SendAvatarProperties(target, "", Util.ToDateTime(0).ToString("M/d/yyyy", CultureInfo.InvariantCulture), new byte [1], "", 0, UUID.Zero, UUID.Zero, "", UUID.Zero); return; } UserInfo TargetPI = remoteClient.Scene.RequestModuleInterface <IAgentInfoService> ().GetUserInfo(target.ToString()); //See if all can see this person uint agentOnline = 0; if (TargetPI != null && TargetPI.IsOnline && UPI.Visible) { agentOnline = 16; } if (IsFriendOfUser(remoteClient.AgentId, target)) { SendProfile(remoteClient, UPI, targetAccount, agentOnline); } else { //Not a friend, so send the first page only and if they are online byte [] charterMember; if (UPI.MembershipGroup == "") { charterMember = new byte [1]; if (targetAccount.Valid) { charterMember [0] = (byte)((targetAccount.UserFlags & Constants.USER_FLAG_CHARTERMEMBER) >> 8); // CharterMember == 0xf00 } } else { charterMember = Utils.StringToBytes(UPI.MembershipGroup); } remoteClient.SendAvatarProperties( UPI.PrincipalID, UPI.AboutText, Util.ToDateTime(UPI.Created).ToString("M/d/yyyy", CultureInfo.InvariantCulture), charterMember, UPI.FirstLifeAboutText, (uint)targetAccount.UserFlags & agentOnline, UPI.FirstLifeImage, UPI.Image, UPI.WebURL, UPI.Partner ); } }
void SendProfile(IClientAPI remoteClient, IUserProfileInfo Profile, UserAccount account, uint agentOnline) { byte[] charterMember; if (Profile.MembershipGroup == "") { charterMember = new byte[1]; if (account != null) { charterMember[0] = (byte)((account.UserFlags & Constants.USER_FLAG_COREDEVELOPER) >> 8); // CharterMember == 0xf00 } } else { charterMember = Utils.StringToBytes(Profile.MembershipGroup); } // When charterMember set this character └ the viewer recognizes it // as a Grid Master. Not sure what we want to do with that in Universe // // Perhaps a talk with viewer devs to allow more options for this if (Utilities.IsSystemUser(Profile.PrincipalID)) { charterMember = Utils.StringToBytes("Virtual Universe System User"); } uint membershipGroupINT = 0; if (Profile.MembershipGroup != "") { membershipGroupINT = 4; } uint flags = Convert.ToUInt32(Profile.AllowPublish) + Convert.ToUInt32(Profile.MaturePublish) + membershipGroupINT + agentOnline + (uint)(account != null ? account.UserFlags : 0); remoteClient.SendAvatarInterestsReply( Profile.PrincipalID, Convert.ToUInt32(Profile.Interests.WantToMask), Profile.Interests.WantToText, Convert.ToUInt32(Profile.Interests.CanDoMask), Profile.Interests.CanDoText, Profile.Interests.Languages ); remoteClient.SendAvatarProperties( Profile.PrincipalID, Profile.AboutText, Util.ToDateTime(Profile.Created).ToString("M/d/yyyy", CultureInfo.InvariantCulture), charterMember, Profile.FirstLifeAboutText, flags, Profile.FirstLifeImage, Profile.Image, Profile.WebURL, Profile.Partner ); }
public IUserProfileInfo GetUserProfile(UUID agentID) { IUserProfileInfo profile = m_localService.GetUserProfile(agentID); if (profile == null) { profile = m_remoteService.GetUserProfile(agentID); } return(profile); }
public bool UpdateUserProfile(IUserProfileInfo Profile) { bool success = m_localService.UpdateUserProfile(Profile); if (!success) { success = m_remoteService.UpdateUserProfile(Profile); } return(success); }
public void RequestAvatarProperty(IClientAPI remoteClient, UUID target) { IUserProfileInfo UPI = ProfileFrontend.GetUserProfile(target); if (UPI == null) { remoteClient.SendAvatarProperties(target, "", Util.ToDateTime(0).ToString("M/d/yyyy", CultureInfo.InvariantCulture), new Byte[1], "", 0, UUID.Zero, UUID.Zero, "", UUID.Zero); return; } UserInfo TargetPI = remoteClient.Scene.RequestModuleInterface <IAgentInfoService>().GetUserInfo(target.ToString()); bool isFriend = IsFriendOfUser(remoteClient.AgentId, target); if (isFriend) { uint agentOnline = 0; if (TargetPI != null && TargetPI.IsOnline) { agentOnline = 16; } SendProfile(remoteClient, UPI, target, agentOnline); } else { UserAccount TargetAccount = GetRegionUserIsIn(remoteClient.AgentId).UserAccountService.GetUserAccount(UUID.Zero, target); //See if all can see this person //Not a friend, so send the first page only and if they are online uint agentOnline = 0; if (TargetPI != null && TargetPI.IsOnline && UPI.Visible) { agentOnline = 16; } Byte[] charterMember; if (UPI.MembershipGroup == "") { charterMember = new Byte[1]; charterMember[0] = (Byte)((TargetAccount.UserFlags & 0xf00) >> 8); } else { charterMember = Utils.StringToBytes(UPI.MembershipGroup); } remoteClient.SendAvatarProperties(UPI.PrincipalID, UPI.AboutText, Util.ToDateTime(UPI.Created).ToString("M/d/yyyy", CultureInfo.InvariantCulture), charterMember, UPI.FirstLifeAboutText, (uint)(TargetAccount.UserFlags & agentOnline), UPI.FirstLifeImage, UPI.Image, UPI.WebURL, UPI.Partner); } }
public void UpdateUserPreferences(bool imViaEmail, bool visible, IClientAPI remoteClient) { IUserProfileInfo UPI = ProfileFrontend.GetUserProfile(remoteClient.AgentId); if (UPI == null) { return; } UPI.Visible = visible; UPI.IMViaEmail = imViaEmail; ProfileFrontend.UpdateUserProfile(UPI); }
public void UserPreferencesRequest(IClientAPI remoteClient) { IUserProfileInfo UPI = ProfileFrontend.GetUserProfile(remoteClient.AgentId); if (UPI == null) { return; } UserAccount account = GetRegionUserIsIn(remoteClient.AgentId).UserAccountService.GetUserAccount(UUID.Zero, remoteClient.AgentId); remoteClient.SendUserInfoReply(UPI.Visible, UPI.IMViaEmail, account.Email); }
/// <summary> /// Set the display name for the given user /// </summary> /// <param name="path"></param> /// <param name="request"></param> /// <param name="httpRequest"></param> /// <param name="httpResponse"></param> /// <returns></returns> byte[] ProcessSetDisplayName(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { try { OSDMap rm = (OSDMap)OSDParser.DeserializeLLSDXml(HttpServerHandlerHelpers.ReadFully(request)); OSDArray display_name = (OSDArray)rm["display_name"]; string oldDisplayName = display_name[0].AsString(); string newDisplayName = display_name[1].AsString(); //Check to see if their name contains a banned character if ( bannedNames.Select(bannedUserName => bannedUserName.Replace(" ", "")) .Any(BannedUserName => newDisplayName.ToLower().Contains(BannedUserName.ToLower()))) { newDisplayName = m_service.ClientCaps.AccountInfo.Name; } IUserProfileInfo info = m_profileConnector.GetUserProfile(m_service.AgentID); if (info == null) { //m_avatar.ControllingClient.SendAlertMessage ("You cannot update your display name currently as your profile cannot be found."); } else { //Set the name info.DisplayName = newDisplayName; m_profileConnector.UpdateUserProfile(info); OSDMap osdname = new OSDMap(); //One for us DisplayNameUpdate(newDisplayName, oldDisplayName, m_service.ClientCaps.AccountInfo, m_service.AgentID); osdname["display_name_next_update"] = OSD.FromDate(DateTime.UtcNow.AddDays(8)); foreach ( IRegionClientCapsService avatar in m_service.RegionCaps.GetClients().Where(avatar => avatar.AgentID != m_service.AgentID)) { //Update all others DisplayNameUpdate(newDisplayName, oldDisplayName, m_service.ClientCaps.AccountInfo, avatar.AgentID); } //The reply SetDisplayNameReply(newDisplayName, oldDisplayName, m_service.ClientCaps.AccountInfo); } } catch { } return(MainServer.BlankResponse); }
public byte[] GetProfile(OSDMap request) { UUID principalID = request["PrincipalID"].AsUUID(); IUserProfileInfo UserProfile = ProfileConnector.GetUserProfile(principalID); OSDMap result = UserProfile != null?UserProfile.ToOSD() : new OSDMap(); string xmlString = OSDParser.SerializeJsonString(result); //m_log.DebugFormat("[AuroraDataServerPostHandler]: resp string: {0}", xmlString); UTF8Encoding encoding = new UTF8Encoding(); return(encoding.GetBytes(xmlString)); }
protected void HandleLoadAvatarProfile(string[] cmdparams) { if (cmdparams.Length != 6) { MainConsole.Instance.Info("[AvatarProfileArchiver] Not enough parameters!"); return; } StreamReader reader = new StreamReader(cmdparams[5]); string document = reader.ReadToEnd(); reader.Close(); reader.Dispose(); string[] lines = document.Split('\n'); List <string> file = new List <string>(lines); Dictionary <string, object> replyData = WebUtils.ParseXmlResponse(file[1]); Dictionary <string, object> results = replyData["result"] as Dictionary <string, object>; UserAccount UDA = new UserAccount { Name = cmdparams[3] + cmdparams[4], PrincipalID = UUID.Random(), ScopeID = UUID.Zero, UserFlags = int.Parse(results["UserFlags"].ToString()), UserLevel = 0, UserTitle = results["UserTitle"].ToString(), Email = results["Email"].ToString(), Created = int.Parse(results["Created"].ToString()) }; //For security... Don't want everyone loading full god mode. UserAccountService.StoreUserAccount(UDA); replyData = WebUtils.ParseXmlResponse(file[2]); IUserProfileInfo UPI = new IUserProfileInfo(); UPI.FromKVP(replyData["result"] as Dictionary <string, object>); //Update the principle ID to the new user. UPI.PrincipalID = UDA.PrincipalID; IProfileConnector profileData = DataManager.DataManager.RequestPlugin <IProfileConnector>(); if (profileData.GetUserProfile(UPI.PrincipalID) == null) { profileData.CreateNewProfile(UPI.PrincipalID); } profileData.UpdateUserProfile(UPI); MainConsole.Instance.Info("[AvatarProfileArchiver] Loaded Avatar Profile from " + cmdparams[5]); }
public void AvatarNotesUpdate(IClientAPI remoteClient, UUID queryTargetID, string queryNotes) { IUserProfileInfo UPI = ProfileFrontend.GetUserProfile(remoteClient.AgentId); if (UPI == null) { return; } string notes = queryNotes; UPI.Notes [queryTargetID.ToString()] = OSD.FromString(notes); ProfileFrontend.UpdateUserProfile(UPI); }
private void PackUserInfo(IUserProfileInfo info, UserAccount account, ref OSDArray agents) { OSDMap agentMap = new OSDMap(); agentMap["username"] = account.Name; agentMap["display_name"] = info.DisplayName; agentMap["display_name_next_update"] = OSD.FromDate(DateTime.ParseExact("1970-01-01 00:00:00 +0", "yyyy-MM-dd hh:mm:ss z", System.Globalization.DateTimeFormatInfo.InvariantInfo).ToUniversalTime()); agentMap["legacy_first_name"] = account.FirstName; agentMap["legacy_last_name"] = account.LastName; agentMap["id"] = info.PrincipalID; agentMap["is_display_name_default"] = isDefaultDisplayName(account.FirstName, account.LastName, account.Name, info.DisplayName); agents.Add(agentMap); }
public void UserPreferencesRequest(IClientAPI remoteClient) { IUserProfileInfo UPI = ProfileFrontend.GetUserProfile(remoteClient.AgentId); if (UPI == null) { return; } UserAccount account = remoteClient.Scene.UserAccountService.GetUserAccount(remoteClient.AllScopeIDs, remoteClient .AgentId); remoteClient.SendUserInfoReply(UPI.Visible, UPI.IMViaEmail, account.Email); }
public IUserProfileInfo GetUserProfile(UUID agentID) { IUserProfileInfo UserProfile = new IUserProfileInfo(); lock (UserProfilesCache) { //Try from the user profile first before getting from the DB if (UserProfilesCache.TryGetValue(agentID, out UserProfile)) { return(UserProfile); } } object remoteValue = DoRemote(agentID); if (remoteValue != null || m_doRemoteOnly) { UserProfile = (IUserProfileInfo)remoteValue; //Add to the cache lock (UserProfilesCache) UserProfilesCache[agentID] = UserProfile; return(UserProfile); } QueryFilter filter = new QueryFilter(); filter.andFilters["ID"] = agentID; filter.andFilters["`Key`"] = "LLProfile"; List <string> query = null; //Grab it from the almost generic interface query = GD.Query(new[] { "Value" }, m_userProfileTable, filter, null, null, null); if (query == null || query.Count == 0) { return(null); } //Pull out the OSDmap OSDMap profile = (OSDMap)OSDParser.DeserializeLLSDXml(query[0]); UserProfile = new IUserProfileInfo(); UserProfile.FromOSD(profile); //Add to the cache lock (UserProfilesCache) UserProfilesCache[agentID] = UserProfile; return(UserProfile); }
byte[] GetProfile(OSDMap map) { OSDMap resp = new OSDMap(); string Name = map["Name"].AsString(); UserAccount account = m_registry.RequestModuleInterface <IUserAccountService>().GetUserAccount(UUID.Zero, Name); if (account != null) { OSDMap accountMap = new OSDMap(); accountMap["Created"] = account.Created; accountMap["PrincipalID"] = account.PrincipalID; TimeSpan diff = DateTime.Now - Util.ToDateTime(account.Created); int years = (int)diff.TotalDays / 356; int days = years > 0 ? (int)diff.TotalDays / years : (int)diff.TotalDays; accountMap["TimeSinceCreated"] = years + " years, " + days + " days"; IProfileConnector profileConnector = Aurora.DataManager.DataManager.RequestPlugin <IProfileConnector>(); IUserProfileInfo profile = profileConnector.GetUserProfile(account.PrincipalID); if (profile != null) { resp["profile"] = profile.ToOSD(false);//not trusted, use false if (account.UserFlags == 0) { account.UserFlags = 2; //Set them to no info given } string flags = ((IUserProfileInfo.ProfileFlags)account.UserFlags).ToString(); IUserProfileInfo.ProfileFlags.NoPaymentInfoOnFile.ToString(); accountMap["AccountInfo"] = (profile.CustomType != "" ? profile.CustomType : account.UserFlags == 0 ? "Resident" : "Admin") + "\n" + flags; UserAccount partnerAccount = m_registry.RequestModuleInterface <IUserAccountService>().GetUserAccount(UUID.Zero, profile.Partner); if (partnerAccount != null) { accountMap["Partner"] = partnerAccount.Name; } else { accountMap["Partner"] = ""; } } resp["account"] = accountMap; } string xmlString = OSDParser.SerializeJsonString(resp); UTF8Encoding encoding = new UTF8Encoding(); return(encoding.GetBytes(xmlString)); }
private void SendProfile(IClientAPI remoteClient, IUserProfileInfo Profile, UserAccount account, uint agentOnline) { Byte[] charterMember; if (Profile.MembershipGroup == "") { charterMember = new Byte[1]; if (account != null) { charterMember[0] = (Byte)((account.UserFlags & Constants.USER_FLAG_CHARTERMEMBER) >> 8); // CharterMember == 0xf00 } } else { charterMember = Utils.StringToBytes(Profile.MembershipGroup); } // When ChaterMember set this character └ the viewer recognizes it // as a Grid Master Not sure what we will be doing with this in // in Virtual Universe. // Perhaps the Viewer Development Work Group on the Second Galaxy Development Team // will shed some light on this regarding future viewer planning. if (Utilities.IsSystemUser(Profile.PrincipalID)) { charterMember = Utils.StringToBytes("└"); } uint membershipGroupINT = 0; if (Profile.MembershipGroup != "") { membershipGroupINT = 4; } uint flags = Convert.ToUInt32(Profile.AllowPublish) + Convert.ToUInt32(Profile.MaturePublish) + membershipGroupINT + agentOnline + (uint)(account != null ? account.UserFlags : 0); remoteClient.SendAvatarInterestsReply(Profile.PrincipalID, Convert.ToUInt32(Profile.Interests.WantToMask), Profile.Interests.WantToText, Convert.ToUInt32(Profile.Interests.CanDoMask), Profile.Interests.CanDoText, Profile.Interests.Languages); remoteClient.SendAvatarProperties(Profile.PrincipalID, Profile.AboutText, Util.ToDateTime(Profile.Created).ToString("M/d/yyyy", CultureInfo.InvariantCulture), charterMember, Profile.FirstLifeAboutText, flags, Profile.FirstLifeImage, Profile.Image, Profile.WebURL, Profile.Partner); }
/// <summary> /// Create a new profile for a user /// </summary> /// <param name="AgentID"></param> public void CreateNewProfile(UUID AgentID) { List <object> values = new List <object> { AgentID.ToString(), "LLProfile" }; //Create a new basic profile for them IUserProfileInfo profile = new IUserProfileInfo { PrincipalID = AgentID }; values.Add(OSDParser.SerializeLLSDXmlString(profile.ToOSD())); //Value which is a default Profile GD.Insert(m_userProfileTable, values.ToArray()); }
public byte[] UpdateProfile(OSDMap request) { IUserProfileInfo UserProfile = new IUserProfileInfo(); UserProfile.FromOSD((OSDMap)request["Profile"]); ProfileConnector.UpdateUserProfile(UserProfile); OSDMap result = new OSDMap(); result["result"] = "Successful"; string xmlString = OSDParser.SerializeJsonString(result); //MainConsole.Instance.DebugFormat("[AuroraDataServerPostHandler]: resp string: {0}", xmlString); UTF8Encoding encoding = new UTF8Encoding(); return(encoding.GetBytes(xmlString)); }
private void PackUserInfo(IUserProfileInfo info, UserAccount account, ref OSDArray agents) { OSDMap agentMap = new OSDMap(); agentMap["username"] = account.Name; agentMap["display_name"] = (info == null || info.DisplayName == "") ? account.Name : info.DisplayName; agentMap["display_name_next_update"] = OSD.FromDate( DateTime.ParseExact("1970-01-01 00:00:00 +0", "yyyy-MM-dd hh:mm:ss z", DateTimeFormatInfo.InvariantInfo).ToUniversalTime()); agentMap["legacy_first_name"] = account.FirstName; agentMap["legacy_last_name"] = account.LastName; agentMap["id"] = account.PrincipalID; agentMap["is_display_name_default"] = isDefaultDisplayName(account.FirstName, account.LastName, account.Name, info == null ? account.Name : info.DisplayName); agents.Add(agentMap); }
private void SendProfile(IClientAPI remoteClient, IUserProfileInfo Profile, UserAccount account, uint agentOnline) { Byte[] charterMember; if (Profile.MembershipGroup == "") { charterMember = new Byte[1]; if (account != null) charterMember[0] = (Byte) ((account.UserFlags & 0xf00) >> 8); } else charterMember = Utils.StringToBytes(Profile.MembershipGroup); uint membershipGroupINT = 0; if (Profile.MembershipGroup != "") membershipGroupINT = 4; uint flags = Convert.ToUInt32(Profile.AllowPublish) + Convert.ToUInt32(Profile.MaturePublish) + membershipGroupINT + agentOnline + (uint) (account != null ? account.UserFlags : 0); remoteClient.SendAvatarInterestsReply(Profile.PrincipalID, Convert.ToUInt32(Profile.Interests.WantToMask), Profile.Interests.WantToText, Convert.ToUInt32(Profile.Interests.CanDoMask), Profile.Interests.CanDoText, Profile.Interests.Languages); remoteClient.SendAvatarProperties(Profile.PrincipalID, Profile.AboutText, Util.ToDateTime(Profile.Created).ToString("M/d/yyyy", CultureInfo.InvariantCulture), charterMember, Profile.FirstLifeAboutText, flags, Profile.FirstLifeImage, Profile.Image, Profile.WebURL, Profile.Partner); }
public bool UpdateUserProfile(IUserProfileInfo Profile) { object remoteValue = DoRemote(Profile); if (remoteValue != null || m_doRemoteOnly) return remoteValue != null && (bool) remoteValue; IUserProfileInfo previousProfile = GetUserProfile(Profile.PrincipalID); //Make sure the previous one exists if (previousProfile == null) return false; //Now fix values that the sim cannot change Profile.Partner = previousProfile.Partner; Profile.CustomType = previousProfile.CustomType; Profile.MembershipGroup = previousProfile.MembershipGroup; Profile.Created = previousProfile.Created; Dictionary<string, object> values = new Dictionary<string, object>(1); values["Value"] = OSDParser.SerializeLLSDXmlString(Profile.ToOSD()); QueryFilter filter = new QueryFilter(); filter.andFilters["ID"] = Profile.PrincipalID.ToString(); filter.andFilters["`Key`"] = "LLProfile"; //Update cache lock(UserProfilesCache) UserProfilesCache[Profile.PrincipalID] = Profile; return GD.Update("userdata", values, null, filter, null, null); }
public IUserProfileInfo GetUserProfile(UUID agentID) { IUserProfileInfo UserProfile = new IUserProfileInfo(); lock (UserProfilesCache) { //Try from the user profile first before getting from the DB if (UserProfilesCache.TryGetValue(agentID, out UserProfile)) return UserProfile; } object remoteValue = DoRemote(agentID); if (remoteValue != null || m_doRemoteOnly) { UserProfile = (IUserProfileInfo)remoteValue; //Add to the cache lock (UserProfilesCache) UserProfilesCache[agentID] = UserProfile; return UserProfile; } QueryFilter filter = new QueryFilter(); filter.andFilters["ID"] = agentID; filter.andFilters["`Key`"] = "LLProfile"; List<string> query = null; //Grab it from the almost generic interface query = GD.Query(new[] {"Value"}, "userdata", filter, null, null, null); if (query == null || query.Count == 0) return null; //Pull out the OSDmap OSDMap profile = (OSDMap) OSDParser.DeserializeLLSDXml(query[0]); UserProfile = new IUserProfileInfo(); UserProfile.FromOSD(profile); //Add to the cache lock(UserProfilesCache) UserProfilesCache[agentID] = UserProfile; return UserProfile; }
/// <summary> /// Create a new profile for a user /// </summary> /// <param name="AgentID"></param> //[CanBeReflected(ThreatLevel = ThreatLevel.Full)] public void CreateNewProfile(UUID AgentID) { /*object remoteValue = DoRemote(AgentID); if (remoteValue != null || m_doRemoteOnly) return;*/ List<object> values = new List<object> {AgentID.ToString(), "LLProfile"}; //Create a new basic profile for them IUserProfileInfo profile = new IUserProfileInfo {PrincipalID = AgentID}; values.Add(OSDParser.SerializeLLSDXmlString(profile.ToOSD())); //Value which is a default Profile GD.Insert("userdata", values.ToArray()); }