/// <summary> /// Gets an avatar's profile using the OpenProfile protocol. /// </summary> /// <param name="props">On success, this will contain the avatar's profile</param> /// <returns>Success/failure</returns> /// <remarks> /// There are two profile modules currently in use in OpenSim: the older one is OpenProfile, and the newer /// one is UserProfileModule (this file). This method attempts to read an avatar's profile from a foreign /// grid using the OpenProfile protocol. /// </remarks> public bool RequestAvatarPropertiesUsingOpenProfile(ref UserProfileProperties props) { Hashtable ReqHash = new Hashtable(); ReqHash["avatar_id"] = props.UserId.ToString(); Hashtable profileData = XMLRPCRequester.SendRequest(ReqHash, "avatar_properties_request", m_serverURI); if (profileData == null) return false; if (!profileData.ContainsKey("data")) return false; ArrayList dataArray = (ArrayList)profileData["data"]; if (dataArray == null || dataArray[0] == null) return false; profileData = (Hashtable)dataArray[0]; props.WebUrl = string.Empty; props.AboutText = String.Empty; props.FirstLifeText = String.Empty; props.ImageId = UUID.Zero; props.FirstLifeImageId = UUID.Zero; props.PartnerId = UUID.Zero; if (profileData["ProfileUrl"] != null) props.WebUrl = profileData["ProfileUrl"].ToString(); if (profileData["AboutText"] != null) props.AboutText = profileData["AboutText"].ToString(); if (profileData["FirstLifeAboutText"] != null) props.FirstLifeText = profileData["FirstLifeAboutText"].ToString(); if (profileData["Image"] != null) props.ImageId = new UUID(profileData["Image"].ToString()); if (profileData["FirstLifeImage"] != null) props.FirstLifeImageId = new UUID(profileData["FirstLifeImage"].ToString()); if (profileData["Partner"] != null) props.PartnerId = new UUID(profileData["Partner"].ToString()); props.WantToMask = 0; props.WantToText = String.Empty; props.SkillsMask = 0; props.SkillsText = String.Empty; props.Language = String.Empty; if (profileData["wantmask"] != null) props.WantToMask = Convert.ToInt32(profileData["wantmask"].ToString()); if (profileData["wanttext"] != null) props.WantToText = profileData["wanttext"].ToString(); if (profileData["skillsmask"] != null) props.SkillsMask = Convert.ToInt32(profileData["skillsmask"].ToString()); if (profileData["skillstext"] != null) props.SkillsText = profileData["skillstext"].ToString(); if (profileData["languages"] != null) props.Language = profileData["languages"].ToString(); return true; }
public bool UpdateAvatarInterests(UserProfileProperties up, ref string result) { string query = string.Empty; query += "UPDATE userprofile SET "; query += "\"profileWantToMask\"=:WantMask, "; query += "\"profileWantToText\"=:WantText,"; query += "\"profileSkillsMask\"=:SkillsMask,"; query += "\"profileSkillsText\"=:SkillsText, "; query += "\"profileLanguages\"=:Languages "; query += "WHERE \"useruuid\"=:uuid"; try { using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) { dbcon.Open(); using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) { cmd.Parameters.Add(m_database.CreateParameter("WantMask", up.WantToMask)); cmd.Parameters.Add(m_database.CreateParameter("WantText", up.WantToText)); cmd.Parameters.Add(m_database.CreateParameter("SkillsMask", up.SkillsMask)); cmd.Parameters.Add(m_database.CreateParameter("SkillsText", up.SkillsText)); cmd.Parameters.Add(m_database.CreateParameter("Languages", up.Language)); cmd.Parameters.Add(m_database.CreateParameter("uuid", up.UserId)); cmd.ExecuteNonQuery(); } } } catch (Exception e) { m_log.Error("[PROFILES_DATA]: UpdateAvatarInterests exception ", e); result = e.Message; return false; } return true; }
public bool UpdateAvatarProperties(ref UserProfileProperties props, ref string result) { string query = string.Empty; query += "UPDATE userprofile SET "; query += "\"profileURL\"=:profileURL, "; query += "\"profileImage\"=:image, "; query += "\"profileAboutText\"=:abouttext,"; query += "\"profileFirstImage\"=:firstlifeimage,"; query += "\"profileFirstText\"=:firstlifetext "; query += "WHERE \"useruuid\"=:uuid"; try { using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) { dbcon.Open(); using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) { cmd.Parameters.Add(m_database.CreateParameter("profileURL", props.WebUrl)); cmd.Parameters.Add(m_database.CreateParameter("image", props.ImageId)); cmd.Parameters.Add(m_database.CreateParameter("abouttext", props.AboutText)); cmd.Parameters.Add(m_database.CreateParameter("firstlifeimage", props.FirstLifeImageId)); cmd.Parameters.Add(m_database.CreateParameter("firstlifetext", props.FirstLifeText)); cmd.Parameters.Add(m_database.CreateParameter("uuid", props.UserId)); cmd.ExecuteNonQuery(); } } } catch (Exception e) { m_log.Error("[PROFILES_DATA]: AgentPropertiesUpdate exception ", e); return false; } return true; }
public void RequestAvatarProperties(IClientAPI remoteClient, UUID avatarID) { if (String.IsNullOrEmpty(avatarID.ToString()) || String.IsNullOrEmpty(remoteClient.AgentId.ToString())) { // Looking for a reason that some viewers are sending null Id's m_log.DebugFormat("[PROFILES]: This should not happen remoteClient.AgentId {0} - avatarID {1}", remoteClient.AgentId, avatarID); return; } // Can't handle NPC yet... ScenePresence p = FindPresence(avatarID); if (null != p) { if (p.PresenceType == PresenceType.Npc) return; } string serverURI = string.Empty; bool foreign = GetUserProfileServerURI(avatarID, out serverURI); UserAccount account = null; Dictionary<string,object> userInfo; if (!foreign) { account = Scene.UserAccountService.GetUserAccount(Scene.RegionInfo.ScopeID, avatarID); } else { userInfo = new Dictionary<string, object>(); } Byte[] charterMember = new Byte[1]; string born = String.Empty; uint flags = 0x00; if (null != account) { if (account.UserTitle == "") { charterMember[0] = (Byte)((account.UserFlags & 0xf00) >> 8); } else { charterMember = Utils.StringToBytes(account.UserTitle); } born = Util.ToDateTime(account.Created).ToString( "M/d/yyyy", CultureInfo.InvariantCulture); flags = (uint)(account.UserFlags & 0xff); } else { if (GetUserAccountData(avatarID, out userInfo) == true) { if ((string)userInfo["user_title"] == "") { charterMember[0] = (Byte)(((Byte)userInfo["user_flags"] & 0xf00) >> 8); } else { charterMember = Utils.StringToBytes((string)userInfo["user_title"]); } int val_born = (int)userInfo["user_created"]; born = Util.ToDateTime(val_born).ToString( "M/d/yyyy", CultureInfo.InvariantCulture); // picky, picky int val_flags = (int)userInfo["user_flags"]; flags = (uint)(val_flags & 0xff); } } UserProfileProperties props = new UserProfileProperties(); string result = string.Empty; props.UserId = avatarID; if (!GetProfileData(ref props, foreign, out result)) { m_log.DebugFormat("Error getting profile for {0}: {1}", avatarID, result); return; } remoteClient.SendAvatarProperties(props.UserId, props.AboutText, born, charterMember , props.FirstLifeText, flags, props.FirstLifeImageId, props.ImageId, props.WebUrl, props.PartnerId); remoteClient.SendAvatarInterestsReply(props.UserId, (uint)props.WantToMask, props.WantToText, (uint)props.SkillsMask, props.SkillsText, props.Language); }
/// <summary> /// Update the avatars interests . /// </summary> /// <param name='remoteClient'> /// Remote client. /// </param> /// <param name='wantmask'> /// Wantmask. /// </param> /// <param name='wanttext'> /// Wanttext. /// </param> /// <param name='skillsmask'> /// Skillsmask. /// </param> /// <param name='skillstext'> /// Skillstext. /// </param> /// <param name='languages'> /// Languages. /// </param> public void AvatarInterestsUpdate(IClientAPI remoteClient, uint wantmask, string wanttext, uint skillsmask, string skillstext, string languages) { UserProfileProperties prop = new UserProfileProperties(); prop.UserId = remoteClient.AgentId; prop.WantToMask = (int)wantmask; prop.WantToText = wanttext; prop.SkillsMask = (int)skillsmask; prop.SkillsText = skillstext; prop.Language = languages; string serverURI = string.Empty; GetUserProfileServerURI(remoteClient.AgentId, out serverURI); object Param = prop; if(!rpc.JsonRpcRequest(ref Param, "avatar_interests_update", serverURI, UUID.Random().ToString())) { remoteClient.SendAgentAlertMessage( "Error updating interests", false); return; } }
/// <summary> /// Update the avatars interests . /// </summary> /// <param name='remoteClient'> /// Remote client. /// </param> /// <param name='wantmask'> /// Wantmask. /// </param> /// <param name='wanttext'> /// Wanttext. /// </param> /// <param name='skillsmask'> /// Skillsmask. /// </param> /// <param name='skillstext'> /// Skillstext. /// </param> /// <param name='languages'> /// Languages. /// </param> public void AvatarInterestsUpdate(IClientAPI remoteClient, uint wantmask, string wanttext, uint skillsmask, string skillstext, string languages) { UserProfileProperties prop = new UserProfileProperties(); prop.UserId = remoteClient.AgentId; prop.WantToMask = (int)wantmask; prop.WantToText = wanttext; prop.SkillsMask = (int)skillsmask; prop.SkillsText = skillstext; prop.Language = languages; string serverURI = string.Empty; GetUserProfileServerURI(remoteClient.AgentId, out serverURI); if(string.IsNullOrWhiteSpace(serverURI)) return; object Param = prop; if(!rpc.JsonRpcRequest(ref Param, "avatar_interests_update", serverURI, UUID.Random().ToString())) { remoteClient.SendAgentAlertMessage( "Error updating interests", false); return; } // flush cache UserProfileCacheEntry uce = null; lock(m_profilesCache) { if(m_profilesCache.TryGetValue(remoteClient.AgentId, out uce) && uce != null) { uce.props = null; } } }
public bool UpdateAvatarProperties(ref UserProfileProperties props, ref string result) { string query = string.Empty; query += "UPDATE userprofile SET "; query += "profileURL=:profileURL, "; query += "profileImage=:image, "; query += "profileAboutText=:abouttext,"; query += "profileFirstImage=:firstlifeimage,"; query += "profileFirstText=:firstlifetext "; query += "WHERE useruuid=:uuid"; try { using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) { dbcon.Open(); using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) { cmd.Parameters.AddWithValue("profileURL", props.WebUrl); cmd.Parameters.AddWithValue("image", props.ImageId.ToString()); cmd.Parameters.AddWithValue("abouttext", props.AboutText); cmd.Parameters.AddWithValue("firstlifeimage", props.FirstLifeImageId.ToString()); cmd.Parameters.AddWithValue("firstlifetext", props.FirstLifeText); cmd.Parameters.AddWithValue("uuid", props.UserId.ToString()); cmd.ExecuteNonQuery(); } } } catch (Exception e) { m_log.DebugFormat("[PROFILES_DATA]" + ": AgentPropertiesUpdate exception {0}", e.Message); return false; } return true; }
public bool GetAvatarProperties(ref UserProfileProperties props, ref string result) { IDataReader reader = null; string query = string.Empty; query += "SELECT * FROM userprofile WHERE "; query += "useruuid = :Id"; using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) { cmd.CommandText = query; cmd.Parameters.AddWithValue(":Id", props.UserId.ToString()); try { reader = cmd.ExecuteReader(); } catch(Exception e) { m_log.DebugFormat("[PROFILES_DATA]" + ": GetAvatarProperties exception {0}", e.Message); result = e.Message; return false; } if(reader != null && reader.Read()) { m_log.DebugFormat("[PROFILES_DATA]" + ": Getting data for {0}.", props.UserId); props.WebUrl = (string)reader["profileURL"]; UUID.TryParse((string)reader["profileImage"], out props.ImageId); props.AboutText = (string)reader["profileAboutText"]; UUID.TryParse((string)reader["profileFirstImage"], out props.FirstLifeImageId); props.FirstLifeText = (string)reader["profileFirstText"]; UUID.TryParse((string)reader["profilePartner"], out props.PartnerId); props.WantToMask = (int)reader["profileWantToMask"]; props.WantToText = (string)reader["profileWantToText"]; props.SkillsMask = (int)reader["profileSkillsMask"]; props.SkillsText = (string)reader["profileSkillsText"]; props.Language = (string)reader["profileLanguages"]; } else { m_log.DebugFormat("[PROFILES_DATA]" + ": No data for {0}", props.UserId); props.WebUrl = string.Empty; props.ImageId = UUID.Zero; props.AboutText = string.Empty; props.FirstLifeImageId = UUID.Zero; props.FirstLifeText = string.Empty; props.PartnerId = UUID.Zero; props.WantToMask = 0; props.WantToText = string.Empty; props.SkillsMask = 0; props.SkillsText = string.Empty; props.Language = string.Empty; props.PublishProfile = false; props.PublishMature = false; query = "INSERT INTO userprofile ("; query += "useruuid, "; query += "profilePartner, "; query += "profileAllowPublish, "; query += "profileMaturePublish, "; query += "profileURL, "; query += "profileWantToMask, "; query += "profileWantToText, "; query += "profileSkillsMask, "; query += "profileSkillsText, "; query += "profileLanguages, "; query += "profileImage, "; query += "profileAboutText, "; query += "profileFirstImage, "; query += "profileFirstText) VALUES ("; query += ":userId, "; query += ":profilePartner, "; query += ":profileAllowPublish, "; query += ":profileMaturePublish, "; query += ":profileURL, "; query += ":profileWantToMask, "; query += ":profileWantToText, "; query += ":profileSkillsMask, "; query += ":profileSkillsText, "; query += ":profileLanguages, "; query += ":profileImage, "; query += ":profileAboutText, "; query += ":profileFirstImage, "; query += ":profileFirstText)"; using (SqliteCommand put = (SqliteCommand)m_connection.CreateCommand()) { put.CommandText = query; put.Parameters.AddWithValue(":userId", props.UserId.ToString()); put.Parameters.AddWithValue(":profilePartner", props.PartnerId.ToString()); put.Parameters.AddWithValue(":profileAllowPublish", props.PublishProfile); put.Parameters.AddWithValue(":profileMaturePublish", props.PublishMature); put.Parameters.AddWithValue(":profileURL", props.WebUrl); put.Parameters.AddWithValue(":profileWantToMask", props.WantToMask); put.Parameters.AddWithValue(":profileWantToText", props.WantToText); put.Parameters.AddWithValue(":profileSkillsMask", props.SkillsMask); put.Parameters.AddWithValue(":profileSkillsText", props.SkillsText); put.Parameters.AddWithValue(":profileLanguages", props.Language); put.Parameters.AddWithValue(":profileImage", props.ImageId.ToString()); put.Parameters.AddWithValue(":profileAboutText", props.AboutText); put.Parameters.AddWithValue(":profileFirstImage", props.FirstLifeImageId.ToString()); put.Parameters.AddWithValue(":profileFirstText", props.FirstLifeText); put.ExecuteNonQuery(); } } } return true; }
public bool AvatarInterestsUpdate(UserProfileProperties prop, ref string result) { return ProfilesData.UpdateAvatarInterests(prop, ref result); }
public bool AvatarPropertiesUpdate(ref UserProfileProperties prop, ref string result) { return ProfilesData.UpdateAvatarProperties(ref prop, ref result); }
public bool AvatarPropertiesRequest(ref UserProfileProperties prop, ref string result) { return ProfilesData.GetAvatarProperties(ref prop, ref result); }
/// <summary> /// Gets the profile data. /// </summary> /// <returns> /// The profile data. /// </returns> bool GetProfileData(ref UserProfileProperties properties, bool foreign, string serverURI, out string message) { if (String.IsNullOrEmpty(serverURI)) { message = "User profile service unknown at this time"; return false; } object Prop = (object)properties; if (!rpc.JsonRpcRequest(ref Prop, "avatar_properties_request", serverURI, UUID.Random().ToString())) { // If it's a foreign user then try again using OpenProfile, in case that's what the grid is using bool secondChanceSuccess = false; if (foreign) { try { OpenProfileClient client = new OpenProfileClient(serverURI); if (client.RequestAvatarPropertiesUsingOpenProfile(ref properties)) secondChanceSuccess = true; } catch (Exception e) { m_log.Debug( string.Format( "[PROFILES]: Request using the OpenProfile API for user {0} to {1} failed", properties.UserId, serverURI), e); // Allow the return 'message' to say "JsonRpcRequest" and not "OpenProfile", because // the most likely reason that OpenProfile failed is that the remote server // doesn't support OpenProfile, and that's not very interesting. } } if (!secondChanceSuccess) { message = string.Format("JsonRpcRequest for user {0} to {1} failed", properties.UserId, serverURI); m_log.DebugFormat("[PROFILES]: {0}", message); return false; } } properties = (UserProfileProperties)Prop; if(foreign) { cacheForeignImage(properties.UserId, properties.ImageId); cacheForeignImage(properties.UserId, properties.FirstLifeImageId); } message = "Success"; return true; }
/// <summary> /// Updates the avatar properties. /// </summary> /// <param name='remoteClient'> /// Remote client. /// </param> /// <param name='newProfile'> /// New profile. /// </param> public void AvatarPropertiesUpdate(IClientAPI remoteClient, UserProfileData newProfile) { if (remoteClient.AgentId == newProfile.ID) { UserProfileProperties prop = new UserProfileProperties(); prop.UserId = remoteClient.AgentId; prop.WebUrl = newProfile.ProfileUrl; prop.ImageId = newProfile.Image; prop.AboutText = newProfile.AboutText; prop.FirstLifeImageId = newProfile.FirstLifeImage; prop.FirstLifeText = newProfile.FirstLifeAboutText; if(!m_allowUserProfileWebURLs) prop.WebUrl =""; string serverURI = string.Empty; GetUserProfileServerURI(remoteClient.AgentId, out serverURI); object Prop = prop; if(!rpc.JsonRpcRequest(ref Prop, "avatar_properties_update", serverURI, UUID.Random().ToString())) { remoteClient.SendAgentAlertMessage( "Error updating properties", false); return; } // flush cache UserProfileCacheEntry uce = null; lock(m_profilesCache) { if(m_profilesCache.TryGetValue(remoteClient.AgentId, out uce) && uce != null) { uce.props = null; } } RequestAvatarProperties(remoteClient, newProfile.ID); } }
public void RequestAvatarProperties(IClientAPI remoteClient, UUID avatarID) { if (String.IsNullOrEmpty(avatarID.ToString()) || String.IsNullOrEmpty(remoteClient.AgentId.ToString())) { // Looking for a reason that some viewers are sending null Id's m_log.DebugFormat("[PROFILES]: This should not happen remoteClient.AgentId {0} - avatarID {1}", remoteClient.AgentId, avatarID); return; } ScenePresence p = FindPresence(avatarID); if (p != null && p.isNPC) { remoteClient.SendAvatarProperties(avatarID, ((INPC)(p.ControllingClient)).profileAbout, ((INPC)(p.ControllingClient)).Born, Utils.StringToBytes("Non Player Character (NPC)"), "NPCs have no life", 0x10, UUID.Zero, ((INPC)(p.ControllingClient)).profileImage, "", UUID.Zero); remoteClient.SendAvatarInterestsReply(avatarID, 0, "", 0, "Getting into trouble", "Droidspeak"); return; } UserProfileProperties props; UserProfileCacheEntry uce = null; lock(m_profilesCache) { if(m_profilesCache.TryGetValue(avatarID, out uce) && uce != null) { if(uce.props != null) { props = uce.props; uint cflags = uce.flags; // if on same region force online if(p != null && !p.IsDeleted) cflags |= 0x10; remoteClient.SendAvatarProperties(props.UserId, props.AboutText, uce.born, uce.membershipType , props.FirstLifeText, cflags, props.FirstLifeImageId, props.ImageId, props.WebUrl, props.PartnerId); remoteClient.SendAvatarInterestsReply(props.UserId, (uint)props.WantToMask, props.WantToText, (uint)props.SkillsMask, props.SkillsText, props.Language); return; } else { if(uce.ClientsWaitingProps == null) uce.ClientsWaitingProps = new HashSet<IClientAPI>(); else if(uce.ClientsWaitingProps.Contains(remoteClient)) return; uce.ClientsWaitingProps.Add(remoteClient); } } else { uce = new UserProfileCacheEntry(); uce.ClientsWaitingProps = new HashSet<IClientAPI>(); uce.ClientsWaitingProps.Add(remoteClient); m_profilesCache.AddOrUpdate(avatarID, uce, PROFILECACHEEXPIRE); } } string serverURI = string.Empty; bool foreign = GetUserProfileServerURI(avatarID, out serverURI); UserAccount account = null; Dictionary<string,object> userInfo; if (!foreign) { account = Scene.UserAccountService.GetUserAccount(Scene.RegionInfo.ScopeID, avatarID); } else { userInfo = new Dictionary<string, object>(); } Byte[] membershipType = new Byte[1]; string born = string.Empty; uint flags = 0x00; if (null != account) { if (account.UserTitle == "") membershipType[0] = (Byte)((account.UserFlags & 0xf00) >> 8); else membershipType = Utils.StringToBytes(account.UserTitle); born = Util.ToDateTime(account.Created).ToString( "M/d/yyyy", CultureInfo.InvariantCulture); flags = (uint)(account.UserFlags & 0xff); } else { if (GetUserAccountData(avatarID, out userInfo) == true) { if ((string)userInfo["user_title"] == "") membershipType[0] = (Byte)(((Byte)userInfo["user_flags"] & 0xf00) >> 8); else membershipType = Utils.StringToBytes((string)userInfo["user_title"]); int val_born = (int)userInfo["user_created"]; if(val_born != 0) born = Util.ToDateTime(val_born).ToString( "M/d/yyyy", CultureInfo.InvariantCulture); // picky, picky int val_flags = (int)userInfo["user_flags"]; flags = (uint)(val_flags & 0xff); } } props = new UserProfileProperties(); props.UserId = avatarID; string result = string.Empty; if(!GetProfileData(ref props, foreign, serverURI, out result)) { props.AboutText ="Profile not available at this time. User may still be unknown to this grid"; } if(!m_allowUserProfileWebURLs) props.WebUrl =""; HashSet<IClientAPI> clients; lock(m_profilesCache) { if(!m_profilesCache.TryGetValue(props.UserId, out uce) || uce == null) uce = new UserProfileCacheEntry(); uce.props = props; uce.born = born; uce.membershipType = membershipType; uce.flags = flags; clients = uce.ClientsWaitingProps; uce.ClientsWaitingProps = null; m_profilesCache.AddOrUpdate(props.UserId, uce, PROFILECACHEEXPIRE); } // if on same region force online if(p != null && !p.IsDeleted) flags |= 0x10; if(clients == null) { remoteClient.SendAvatarProperties(props.UserId, props.AboutText, born, membershipType , props.FirstLifeText, flags, props.FirstLifeImageId, props.ImageId, props.WebUrl, props.PartnerId); remoteClient.SendAvatarInterestsReply(props.UserId, (uint)props.WantToMask, props.WantToText, (uint)props.SkillsMask, props.SkillsText, props.Language); } else { if(!clients.Contains(remoteClient)) clients.Add(remoteClient); foreach(IClientAPI cli in clients) { if(!cli.IsActive) continue; cli.SendAvatarProperties(props.UserId, props.AboutText, born, membershipType , props.FirstLifeText, flags, props.FirstLifeImageId, props.ImageId, props.WebUrl, props.PartnerId); cli.SendAvatarInterestsReply(props.UserId, (uint)props.WantToMask, props.WantToText, (uint)props.SkillsMask, props.SkillsText, props.Language); } } }
public bool UpdateAvatarProperties(ref UserProfileProperties props, ref string result) { string query = string.Empty; query += "UPDATE userprofile SET "; query += "profileURL=:profileURL, "; query += "profileImage=:image, "; query += "profileAboutText=:abouttext,"; query += "profileFirstImage=:firstlifeimage,"; query += "profileFirstText=:firstlifetext "; query += "WHERE useruuid=:uuid"; try { using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) { cmd.CommandText = query; cmd.Parameters.AddWithValue(":profileURL", props.WebUrl); cmd.Parameters.AddWithValue(":image", props.ImageId.ToString()); cmd.Parameters.AddWithValue(":abouttext", props.AboutText); cmd.Parameters.AddWithValue(":firstlifeimage", props.FirstLifeImageId.ToString()); cmd.Parameters.AddWithValue(":firstlifetext", props.FirstLifeText); cmd.Parameters.AddWithValue(":uuid", props.UserId.ToString()); cmd.ExecuteNonQuery(); } } catch (Exception e) { m_log.ErrorFormat("[PROFILES_DATA]" + ": AgentPropertiesUpdate exception {0}", e.Message); return false; } return true; }
public bool AvatarInterestsUpdate(OSDMap json, ref JsonRpcResponse response) { if(!json.ContainsKey("params")) { response.Error.Code = ErrorCode.ParseError; response.Error.Message = "no parameters supplied"; m_log.DebugFormat ("Avatar Interests Update Request"); return false; } string result = string.Empty; UserProfileProperties props = new UserProfileProperties(); object Props = (object)props; OSD.DeserializeMembers(ref Props, (OSDMap)json["params"]); if(Service.AvatarInterestsUpdate(props, ref result)) { response.Result = OSD.SerializeMembers(props); return true; } response.Error.Code = ErrorCode.InternalError; response.Error.Message = string.Format("{0}", result); return false; }
public bool UpdateAvatarInterests(UserProfileProperties up, ref string result) { string query = string.Empty; query += "UPDATE userprofile SET "; query += "profileWantToMask=:WantMask, "; query += "profileWantToText=:WantText,"; query += "profileSkillsMask=:SkillsMask,"; query += "profileSkillsText=:SkillsText, "; query += "profileLanguages=:Languages "; query += "WHERE useruuid=:uuid"; try { using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) { cmd.CommandText = query; cmd.Parameters.AddWithValue(":WantMask", up.WantToMask); cmd.Parameters.AddWithValue(":WantText", up.WantToText); cmd.Parameters.AddWithValue(":SkillsMask", up.SkillsMask); cmd.Parameters.AddWithValue(":SkillsText", up.SkillsText); cmd.Parameters.AddWithValue(":Languages", up.Language); cmd.Parameters.AddWithValue(":uuid", up.UserId.ToString()); cmd.ExecuteNonQuery(); } } catch (Exception e) { m_log.ErrorFormat("[PROFILES_DATA]" + ": AgentInterestsUpdate exception {0}", e.Message); result = e.Message; return false; } return true; }
/// <summary> /// Updates the avatar properties. /// </summary> /// <param name='remoteClient'> /// Remote client. /// </param> /// <param name='newProfile'> /// New profile. /// </param> public void AvatarPropertiesUpdate(IClientAPI remoteClient, UserProfileData newProfile) { if (remoteClient.AgentId == newProfile.ID) { UserProfileProperties prop = new UserProfileProperties(); prop.UserId = remoteClient.AgentId; prop.WebUrl = newProfile.ProfileUrl; prop.ImageId = newProfile.Image; prop.AboutText = newProfile.AboutText; prop.FirstLifeImageId = newProfile.FirstLifeImage; prop.FirstLifeText = newProfile.FirstLifeAboutText; string serverURI = string.Empty; GetUserProfileServerURI(remoteClient.AgentId, out serverURI); object Prop = prop; if(!rpc.JsonRpcRequest(ref Prop, "avatar_properties_update", serverURI, UUID.Random().ToString())) { remoteClient.SendAgentAlertMessage( "Error updating properties", false); return; } RequestAvatarProperties(remoteClient, newProfile.ID); } }
public bool GetAvatarProperties(ref UserProfileProperties props, ref string result) { string query = string.Empty; query += "SELECT * FROM userprofile WHERE "; query += "useruuid = :Id"; try { using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) { dbcon.Open(); using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) { cmd.Parameters.AddWithValue("Id", props.UserId.ToString()); using (NpgsqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) { if(reader.HasRows) { m_log.DebugFormat("[PROFILES_DATA]" + ": Getting data for {0}.", props.UserId); reader.Read(); props.WebUrl = (string)reader["profileURL"]; UUID.TryParse((string)reader["profileImage"], out props.ImageId); props.AboutText = (string)reader["profileAboutText"]; UUID.TryParse((string)reader["profileFirstImage"], out props.FirstLifeImageId); props.FirstLifeText = (string)reader["profileFirstText"]; UUID.TryParse((string)reader["profilePartner"], out props.PartnerId); props.WantToMask = (int)reader["profileWantToMask"]; props.WantToText = (string)reader["profileWantToText"]; props.SkillsMask = (int)reader["profileSkillsMask"]; props.SkillsText = (string)reader["profileSkillsText"]; props.Language = (string)reader["profileLanguages"]; } else { m_log.DebugFormat("[PROFILES_DATA]" + ": No data for {0}", props.UserId); props.WebUrl = string.Empty; props.ImageId = UUID.Zero; props.AboutText = string.Empty; props.FirstLifeImageId = UUID.Zero; props.FirstLifeText = string.Empty; props.PartnerId = UUID.Zero; props.WantToMask = 0; props.WantToText = string.Empty; props.SkillsMask = 0; props.SkillsText = string.Empty; props.Language = string.Empty; props.PublishProfile = false; props.PublishMature = false; query = "INSERT INTO userprofile ("; query += "useruuid, "; query += "profilePartner, "; query += "profileAllowPublish, "; query += "profileMaturePublish, "; query += "profileURL, "; query += "profileWantToMask, "; query += "profileWantToText, "; query += "profileSkillsMask, "; query += "profileSkillsText, "; query += "profileLanguages, "; query += "profileImage, "; query += "profileAboutText, "; query += "profileFirstImage, "; query += "profileFirstText) VALUES ("; query += ":userId, "; query += ":profilePartner, "; query += ":profileAllowPublish, "; query += ":profileMaturePublish, "; query += ":profileURL, "; query += ":profileWantToMask, "; query += ":profileWantToText, "; query += ":profileSkillsMask, "; query += ":profileSkillsText, "; query += ":profileLanguages, "; query += ":profileImage, "; query += ":profileAboutText, "; query += ":profileFirstImage, "; query += ":profileFirstText)"; dbcon.Close(); dbcon.Open(); using (NpgsqlCommand put = new NpgsqlCommand(query, dbcon)) { put.Parameters.AddWithValue("userId", props.UserId.ToString()); put.Parameters.AddWithValue("profilePartner", props.PartnerId.ToString()); put.Parameters.AddWithValue("profileAllowPublish", props.PublishProfile); put.Parameters.AddWithValue("profileMaturePublish", props.PublishMature); put.Parameters.AddWithValue("profileURL", props.WebUrl); put.Parameters.AddWithValue("profileWantToMask", props.WantToMask); put.Parameters.AddWithValue("profileWantToText", props.WantToText); put.Parameters.AddWithValue("profileSkillsMask", props.SkillsMask); put.Parameters.AddWithValue("profileSkillsText", props.SkillsText); put.Parameters.AddWithValue("profileLanguages", props.Language); put.Parameters.AddWithValue("profileImage", props.ImageId.ToString()); put.Parameters.AddWithValue("profileAboutText", props.AboutText); put.Parameters.AddWithValue("profileFirstImage", props.FirstLifeImageId.ToString()); put.Parameters.AddWithValue("profileFirstText", props.FirstLifeText); put.ExecuteNonQuery(); } } } } } } catch (Exception e) { m_log.DebugFormat("[PROFILES_DATA]" + ": Requst properties exception {0}", e.Message); result = e.Message; return false; } return true; }
/// <summary> /// Gets the profile data. /// </summary> /// <returns> /// The profile data. /// </returns> bool GetProfileData(ref UserProfileProperties properties, bool foreign, out string message) { // Can't handle NPC yet... ScenePresence p = FindPresence(properties.UserId); if (null != p) { if (p.PresenceType == PresenceType.Npc) { message = "Id points to NPC"; return false; } } string serverURI = string.Empty; GetUserProfileServerURI(properties.UserId, out serverURI); // This is checking a friend on the home grid // Not HG friend if (String.IsNullOrEmpty(serverURI)) { message = "No Presence - foreign friend"; return false; } object Prop = (object)properties; if (!rpc.JsonRpcRequest(ref Prop, "avatar_properties_request", serverURI, UUID.Random().ToString())) { // If it's a foreign user then try again using OpenProfile, in case that's what the grid is using bool secondChanceSuccess = false; if (foreign) { try { OpenProfileClient client = new OpenProfileClient(serverURI); if (client.RequestAvatarPropertiesUsingOpenProfile(ref properties)) secondChanceSuccess = true; } catch (Exception e) { m_log.Debug(string.Format("Request using the OpenProfile API to {0} failed", serverURI), e); // Allow the return 'message' to say "JsonRpcRequest" and not "OpenProfile", because // the most likely reason that OpenProfile failed is that the remote server // doesn't support OpenProfile, and that's not very interesting. } } if (!secondChanceSuccess) { message = string.Format("JsonRpcRequest to {0} failed", serverURI); return false; } // else, continue below } properties = (UserProfileProperties)Prop; message = "Success"; return true; }
public bool UpdateAvatarInterests(UserProfileProperties up, ref string result) { string query = string.Empty; query += "UPDATE userprofile SET "; query += "profileWantToMask=:WantMask, "; query += "profileWantToText=:WantText,"; query += "profileSkillsMask=:SkillsMask,"; query += "profileSkillsText=:SkillsText, "; query += "profileLanguages=:Languages "; query += "WHERE useruuid=:uuid"; try { using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) { dbcon.Open(); using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) { cmd.Parameters.AddWithValue("WantMask", up.WantToMask); cmd.Parameters.AddWithValue("WantText", up.WantToText); cmd.Parameters.AddWithValue("SkillsMask", up.SkillsMask); cmd.Parameters.AddWithValue("SkillsText", up.SkillsText); cmd.Parameters.AddWithValue("Languages", up.Language); cmd.Parameters.AddWithValue("uuid", up.UserId.ToString()); cmd.ExecuteNonQuery(); } } } catch (Exception e) { m_log.DebugFormat("[PROFILES_DATA]" + ": AgentInterestsUpdate exception {0}", e.Message); result = e.Message; return false; } return true; }
/// <summary> /// Gets the profile data. /// </summary> /// <returns> /// The profile data. /// </returns> /// <param name='userID'> /// User I. /// </param> bool GetProfileData(ref UserProfileProperties properties, out string message) { // Can't handle NPC yet... ScenePresence p = FindPresence(properties.UserId); if (null != p) { if (p.PresenceType == PresenceType.Npc) { message = "Id points to NPC"; return false; } } string serverURI = string.Empty; GetUserProfileServerURI(properties.UserId, out serverURI); // This is checking a friend on the home grid // Not HG friend if ( String.IsNullOrEmpty(serverURI)) { message = "No Presence - foreign friend"; return false; } object Prop = (object)properties; JsonRpcRequest(ref Prop, "avatar_properties_request", serverURI, UUID.Random().ToString()); properties = (UserProfileProperties)Prop; message = "Success"; return true; }