/// <summary> /// Tries to implement the Get [] semantics, but it cuts corners. /// Specifically, it gets all friendships even if they weren't accepted yet. /// </summary> /// <param name="fields"></param> /// <param name="values"></param> /// <returns></returns> public FriendsData[] GetFriends(string userID) { List <FriendsData> lst = m_Data.FindAll(fdata => { return(fdata.PrincipalID == userID.ToString()); }); if (lst != null) { lst.ForEach(f => { FriendsData f2 = m_Data.Find(candidateF2 => f.Friend == candidateF2.PrincipalID); if (f2 != null) { f.Data["TheirFlags"] = f2.Data["Flags"]; } // m_log.DebugFormat( // "[NULL FRIENDS DATA]: Got {0} {1} {2} for {3}", // f.Friend, f.Data["Flags"], f2 != null ? f.Data["TheirFlags"] : "not found!", f.PrincipalID); }); // m_log.DebugFormat("[NULL FRIENDS DATA]: Got {0} friends for {1}", lst.Count, userID); return(lst.ToArray()); } return(new FriendsData[0]); }
public XmlRpcResponse XmlRpcUpdateWelcomeMethod(XmlRpcRequest request, IPEndPoint remoteClient) { m_log.Info("[Concierge]: processing UpdateWelcome request"); XmlRpcResponse response = new XmlRpcResponse(); Hashtable responseData = new Hashtable(); try { Hashtable requestData = (Hashtable)request.Params[0]; checkStringParameters(request, new string[] { "password", "region", "welcome" }); // check password if (!String.IsNullOrEmpty(m_xmlRpcPassword) && (string)requestData["password"] != m_xmlRpcPassword) { throw new Exception("wrong password"); } if (String.IsNullOrEmpty(m_welcomes)) { throw new Exception("welcome templates are not enabled, ask your OpenSim operator to set the \"welcomes\" option in the [Concierge] section of OpenSim.ini"); } string msg = (string)requestData["welcome"]; if (String.IsNullOrEmpty(msg)) { throw new Exception("empty parameter \"welcome\""); } string regionName = (string)requestData["region"]; IScene scene = m_scenes.Find(delegate(IScene s) { return(s.RegionInfo.RegionName == regionName); }); if (scene == null) { throw new Exception(String.Format("unknown region \"{0}\"", regionName)); } if (!m_conciergedScenes.Contains(scene)) { throw new Exception(String.Format("region \"{0}\" is not a concierged region.", regionName)); } string welcome = Path.Combine(m_welcomes, regionName); if (File.Exists(welcome)) { m_log.InfoFormat("[Concierge]: UpdateWelcome: updating existing template \"{0}\"", welcome); string welcomeBackup = String.Format("{0}~", welcome); if (File.Exists(welcomeBackup)) { File.Delete(welcomeBackup); } File.Move(welcome, welcomeBackup); } File.WriteAllText(welcome, msg); responseData["success"] = "true"; response.Value = responseData; } catch (Exception e) { m_log.InfoFormat("[Concierge]: UpdateWelcome failed: {0}", e.Message); responseData["success"] = "false"; responseData["error"] = e.Message; response.Value = responseData; } m_log.Debug("[Concierge]: done processing UpdateWelcome request"); return(response); }