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); }
/// <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); }
/// <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); } RequestAvatarProperties(remoteClient, newProfile.ID); } }
public bool UpdateAvatarProperties(ref UserProfileProperties props, ref string result) { const string query = "UPDATE userprofile SET profileURL=?profileURL," + "profileImage=?image, profileAboutText=?abouttext," + "profileFirstImage=?firstlifeimage, profileFirstText=?firstlifetext " + "WHERE useruuid=?uuid"; try { using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) { dbcon.Open(); using (MySqlCommand cmd = new MySqlCommand(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(); } dbcon.Close(); } } catch (Exception e) { m_log.ErrorFormat("[PROFILES_DATA]: UpdateAvatarProperties exception {0}", e.Message); return(false); } return(true); }
/// <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 UpdateAvatarProperties(ref UserProfileProperties props, ref string result) { string query = string.Empty; query += "UPDATE userprofile SET "; query += "profilePartner=:profilePartner, "; 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("profilePartner", props.PartnerId.ToString()); 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 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 (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) { dbcon.Open(); using (MySqlCommand cmd = new MySqlCommand(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); }
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); }
/// <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); } }
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.DebugFormat("[PROFILES_DATA]" + ": AgentInterestsUpdate exception {0}", e.Message); 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 (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 GetAvatarProperties(ref UserProfileProperties props, ref string result) { string query = string.Empty; query += "SELECT * FROM userprofile WHERE "; query += "useruuid = ?Id"; try { using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) { dbcon.Open(); using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) { cmd.Parameters.AddWithValue("?Id", props.UserId.ToString()); using (MySqlDataReader 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 (MySqlCommand put = new MySqlCommand(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); }
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()) { 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 { 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)); }
/// <summary> /// Gets the profile data. /// </summary> /// <returns> /// The profile data. /// </returns> private 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 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.Add(m_database.CreateParameter("Id", props.UserId)); 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"].ToString(); props.ImageId = DBGuid.FromDB(reader["profileImage"]); props.AboutText = (string)reader["profileAboutText"]; props.FirstLifeImageId = DBGuid.FromDB(reader["profileFirstImage"]); props.FirstLifeText = (string)reader["profileFirstText"]; props.PartnerId = DBGuid.FromDB(reader["profilePartner"]); 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)) { //m_log.DebugFormat("[PROFILES_DATA]" + // ": Adding new data for {0}", props.UserId); put.Parameters.Add(m_database.CreateParameter("userId", props.UserId)); put.Parameters.Add(m_database.CreateParameter("profilePartner", props.PartnerId)); put.Parameters.Add(m_database.CreateParameter("profileAllowPublish", props.PublishProfile)); put.Parameters.Add(m_database.CreateParameter("profileMaturePublish", props.PublishMature)); put.Parameters.Add(m_database.CreateParameter("profileURL", props.WebUrl)); put.Parameters.Add(m_database.CreateParameter("profileWantToMask", props.WantToMask)); put.Parameters.Add(m_database.CreateParameter("profileWantToText", props.WantToText)); put.Parameters.Add(m_database.CreateParameter("profileSkillsMask", props.SkillsMask)); put.Parameters.Add(m_database.CreateParameter("profileSkillsText", props.SkillsText)); put.Parameters.Add(m_database.CreateParameter("profileLanguages", props.Language)); put.Parameters.Add(m_database.CreateParameter("profileImage", props.ImageId)); put.Parameters.Add(m_database.CreateParameter("profileAboutText", props.AboutText)); put.Parameters.Add(m_database.CreateParameter("profileFirstImage", props.FirstLifeImageId)); put.Parameters.Add(m_database.CreateParameter("profileFirstText", props.FirstLifeText)); put.ExecuteNonQuery(); } } } } } } catch (Exception e) { m_log.Error("[PROFILES_DATA]: GetAvatarProperties exception ", e); result = e.Message; return(false); } return(true); }
public bool AvatarPropertiesRequest(ref UserProfileProperties prop, ref string result) { return(ProfilesData.GetAvatarProperties(ref prop, ref result)); }
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); }