PageRenderTime 90ms CodeModel.GetById 41ms RepoModel.GetById 1ms app.codeStats 0ms

/Concierge/Modules/ConciergeModule.cs

https://bitbucket.org/VirtualReality/optional-modules
C# | 637 lines | 476 code | 87 blank | 74 comment | 57 complexity | 0fd6dd1213eed990b0dbabfab94a818b MD5 | raw file
  1. /*
  2. * Copyright (c) Contributors, http://aurora-sim.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the Aurora-Sim Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections;
  29. using System.Collections.Generic;
  30. using System.IO;
  31. using System.Net;
  32. using System.Net.Sockets;
  33. using System.Reflection;
  34. using System.Text;
  35. using System.Text.RegularExpressions;
  36. using System.Threading;
  37. using log4net;
  38. using Nini.Config;
  39. using Nwc.XmlRpc;
  40. using OpenMetaverse;
  41. using Aurora.Framework;
  42. using OpenSim.Region.Framework.Interfaces;
  43. using OpenSim.Region.Framework.Scenes;
  44. using Aurora.Modules.Chat;
  45. namespace OpenSim.Region.OptionalModules.Avatar.Concierge
  46. {
  47. public class ConciergeModule : AuroraChatModule, ISharedRegionModule
  48. {
  49. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  50. private const int DEBUG_CHANNEL = 2147483647;
  51. private List<IScene> m_scenes = new List<IScene>();
  52. private List<IScene> m_conciergedScenes = new List<IScene>();
  53. private bool m_replacingChatModule = false;
  54. private IConfig m_config;
  55. private string m_whoami = "conferencier";
  56. private Regex m_regions = null;
  57. private string m_welcomes = null;
  58. private int m_conciergeChannel = 42;
  59. private string m_announceEntering = "{0} enters {1} (now {2} visitors in this region)";
  60. private string m_announceLeaving = "{0} leaves {1} (back to {2} visitors in this region)";
  61. private string m_xmlRpcPassword = String.Empty;
  62. private string m_brokerURI = String.Empty;
  63. private int m_brokerUpdateTimeout = 300;
  64. internal object m_syncy = new object();
  65. internal bool m_enabled = false;
  66. #region ISharedRegionModule Members
  67. public override void Initialise(IConfigSource config)
  68. {
  69. m_config = config.Configs["Concierge"];
  70. if (null == m_config)
  71. {
  72. //m_log.Info("[Concierge]: no config found, plugin disabled");
  73. return;
  74. }
  75. if (!m_config.GetBoolean("enabled", false))
  76. {
  77. //m_log.Info("[Concierge]: plugin disabled by configuration");
  78. return;
  79. }
  80. m_enabled = true;
  81. // check whether ChatModule has been disabled: if yes,
  82. // then we'll "stand in"
  83. try
  84. {
  85. if (config.Configs["Chat"] == null)
  86. {
  87. // if Chat module has not been configured it's
  88. // enabled by default, so we are not going to
  89. // replace it.
  90. m_replacingChatModule = false;
  91. }
  92. else
  93. {
  94. m_replacingChatModule = !config.Configs["Chat"].GetBoolean("enabled", true);
  95. }
  96. }
  97. catch (Exception)
  98. {
  99. m_replacingChatModule = false;
  100. }
  101. m_log.InfoFormat("[Concierge] {0} ChatModule", m_replacingChatModule ? "replacing" : "not replacing");
  102. // take note of concierge channel and of identity
  103. m_conciergeChannel = config.Configs["Concierge"].GetInt("concierge_channel", m_conciergeChannel);
  104. m_whoami = m_config.GetString("whoami", "conferencier");
  105. m_welcomes = m_config.GetString("welcomes", m_welcomes);
  106. m_announceEntering = m_config.GetString("announce_entering", m_announceEntering);
  107. m_announceLeaving = m_config.GetString("announce_leaving", m_announceLeaving);
  108. m_xmlRpcPassword = m_config.GetString("password", m_xmlRpcPassword);
  109. m_brokerURI = m_config.GetString("broker", m_brokerURI);
  110. m_brokerUpdateTimeout = m_config.GetInt("broker_timeout", m_brokerUpdateTimeout);
  111. m_log.InfoFormat("[Concierge] reporting as \"{0}\" to our users", m_whoami);
  112. // calculate regions Regex
  113. if (m_regions == null)
  114. {
  115. string regions = m_config.GetString("regions", String.Empty);
  116. if (!String.IsNullOrEmpty(regions))
  117. {
  118. m_regions = new Regex(@regions, RegexOptions.Compiled | RegexOptions.IgnoreCase);
  119. }
  120. }
  121. }
  122. public override void AddRegion(IScene scene)
  123. {
  124. if (!m_enabled) return;
  125. MainServer.Instance.AddXmlRPCHandler("concierge_update_welcome", XmlRpcUpdateWelcomeMethod, false);
  126. lock (m_syncy)
  127. {
  128. m_scenes.Add (scene);
  129. if (m_regions == null || m_regions.IsMatch (scene.RegionInfo.RegionName))
  130. m_conciergedScenes.Add (scene);
  131. // subscribe to NewClient events
  132. scene.EventManager.OnNewClient += OnNewClient;
  133. scene.EventManager.OnClosingClient += OnClientLoggedOut;
  134. // subscribe to *Chat events
  135. scene.EventManager.OnChatFromWorld += OnChatFromWorld;
  136. if (!m_replacingChatModule)
  137. scene.EventManager.OnChatFromClient += OnChatFromClient;
  138. scene.EventManager.OnChatBroadcast += OnChatBroadcast;
  139. // subscribe to agent change events
  140. scene.EventManager.OnMakeRootAgent += OnMakeRootAgent;
  141. scene.EventManager.OnMakeChildAgent += OnMakeChildAgent;
  142. }
  143. m_log.InfoFormat("[Concierge]: initialized for {0}", scene.RegionInfo.RegionName);
  144. }
  145. public override void RemoveRegion(IScene scene)
  146. {
  147. if (!m_enabled) return;
  148. MainServer.Instance.RemoveXmlRPCHandler("concierge_update_welcome");
  149. lock (m_syncy)
  150. {
  151. // unsubscribe from NewClient events
  152. scene.EventManager.OnNewClient -= OnNewClient;
  153. scene.EventManager.OnClosingClient -= OnClientLoggedOut;
  154. // unsubscribe from *Chat events
  155. scene.EventManager.OnChatFromWorld -= OnChatFromWorld;
  156. if (!m_replacingChatModule)
  157. scene.EventManager.OnChatFromClient -= OnChatFromClient;
  158. scene.EventManager.OnChatBroadcast -= OnChatBroadcast;
  159. // unsubscribe from agent change events
  160. scene.EventManager.OnMakeRootAgent -= OnMakeRootAgent;
  161. scene.EventManager.OnMakeChildAgent -= OnMakeChildAgent;
  162. m_scenes.Remove(scene);
  163. m_conciergedScenes.Remove(scene);
  164. }
  165. m_log.InfoFormat("[Concierge]: removed {0}", scene.RegionInfo.RegionName);
  166. }
  167. public override void PostInitialise()
  168. {
  169. }
  170. public override void Close()
  171. {
  172. }
  173. new public Type ReplaceableInterface
  174. {
  175. get { return null; }
  176. }
  177. public override string Name
  178. {
  179. get { return "ConciergeModule"; }
  180. }
  181. #endregion
  182. #region ISimChat Members
  183. protected override void OnChatBroadcast(Object sender, OSChatMessage c)
  184. {
  185. if (m_replacingChatModule)
  186. {
  187. // distribute chat message to each and every avatar in
  188. // the region
  189. base.OnChatBroadcast(sender, c);
  190. }
  191. // TODO: capture logic
  192. return;
  193. }
  194. protected override void OnChatFromClient (IClientAPI sender, OSChatMessage c)
  195. {
  196. if (m_replacingChatModule)
  197. {
  198. // replacing ChatModule: need to redistribute
  199. // ChatFromClient to interested subscribers
  200. c = FixPositionOfChatMessage(c);
  201. IScene scene = c.Scene;
  202. scene.EventManager.TriggerOnChatFromClient(sender, c);
  203. if (m_conciergedScenes.Contains(c.Scene))
  204. {
  205. // when we are replacing ChatModule, we treat
  206. // OnChatFromClient like OnChatBroadcast for
  207. // concierged regions, effectively extending the
  208. // range of chat to cover the whole
  209. // region. however, we don't do this for whisper
  210. // (got to have some privacy)
  211. if (c.Type != ChatTypeEnum.Whisper)
  212. {
  213. base.OnChatBroadcast(sender, c);
  214. return;
  215. }
  216. }
  217. // redistribution will be done by base class
  218. base.OnChatFromClient(sender, c);
  219. }
  220. // TODO: capture chat
  221. return;
  222. }
  223. public override void OnChatFromWorld(Object sender, OSChatMessage c)
  224. {
  225. if (m_replacingChatModule)
  226. {
  227. if (m_conciergedScenes.Contains(c.Scene))
  228. {
  229. // when we are replacing ChatModule, we treat
  230. // OnChatFromClient like OnChatBroadcast for
  231. // concierged regions, effectively extending the
  232. // range of chat to cover the whole
  233. // region. however, we don't do this for whisper
  234. // (got to have some privacy)
  235. if (c.Type != ChatTypeEnum.Whisper)
  236. {
  237. base.OnChatBroadcast(sender, c);
  238. return;
  239. }
  240. }
  241. base.OnChatFromWorld(sender, c);
  242. }
  243. return;
  244. }
  245. #endregion
  246. public override void OnNewClient(IClientAPI client)
  247. {
  248. client.OnLogout += OnClientLoggedOut;
  249. if (m_replacingChatModule)
  250. client.OnChatFromClient += OnChatFromClient;
  251. }
  252. public void OnClientLoggedOut(IClientAPI client)
  253. {
  254. client.OnLogout -= OnClientLoggedOut;
  255. client.OnConnectionClosed -= OnClientLoggedOut;
  256. if (m_replacingChatModule)
  257. client.OnChatFromClient -= OnChatFromClient;
  258. if (m_conciergedScenes.Contains(client.Scene))
  259. {
  260. IScene scene = client.Scene;
  261. IEntityCountModule entityCountModule = client.Scene.RequestModuleInterface<IEntityCountModule>();
  262. if (entityCountModule != null)
  263. {
  264. m_log.DebugFormat("[Concierge]: {0} logs off from {1}", client.Name, scene.RegionInfo.RegionName);
  265. AnnounceToAgentsRegion(scene, String.Format(m_announceLeaving, client.Name, scene.RegionInfo.RegionName, entityCountModule.RootAgents));
  266. UpdateBroker(scene);
  267. }
  268. }
  269. }
  270. public void OnMakeRootAgent (IScenePresence agent)
  271. {
  272. if (m_conciergedScenes.Contains(agent.Scene))
  273. {
  274. IScene scene = agent.Scene;
  275. m_log.DebugFormat("[Concierge]: {0} enters {1}", agent.Name, scene.RegionInfo.RegionName);
  276. WelcomeAvatar(agent, scene);
  277. IEntityCountModule entityCountModule = scene.RequestModuleInterface<IEntityCountModule>();
  278. if (entityCountModule != null)
  279. {
  280. AnnounceToAgentsRegion(scene, String.Format(m_announceEntering, agent.Name,
  281. scene.RegionInfo.RegionName, entityCountModule.RootAgents));
  282. UpdateBroker(scene);
  283. }
  284. }
  285. }
  286. public void OnMakeChildAgent (IScenePresence agent, OpenSim.Services.Interfaces.GridRegion destination)
  287. {
  288. if (m_conciergedScenes.Contains(agent.Scene))
  289. {
  290. IScene scene = agent.Scene;
  291. m_log.DebugFormat("[Concierge]: {0} leaves {1}", agent.Name, scene.RegionInfo.RegionName);
  292. IEntityCountModule entityCountModule = scene.RequestModuleInterface<IEntityCountModule>();
  293. if (entityCountModule != null)
  294. {
  295. AnnounceToAgentsRegion(scene, String.Format(m_announceLeaving, agent.Name,
  296. scene.RegionInfo.RegionName, entityCountModule.RootAgents));
  297. UpdateBroker(scene);
  298. }
  299. }
  300. }
  301. internal class BrokerState
  302. {
  303. public string Uri;
  304. public string Payload;
  305. public HttpWebRequest Poster;
  306. public Timer Timer;
  307. public BrokerState(string uri, string payload, HttpWebRequest poster)
  308. {
  309. Uri = uri;
  310. Payload = payload;
  311. Poster = poster;
  312. }
  313. }
  314. protected void UpdateBroker(IScene scene)
  315. {
  316. if (String.IsNullOrEmpty(m_brokerURI))
  317. return;
  318. string uri = String.Format(m_brokerURI, scene.RegionInfo.RegionName, scene.RegionInfo.RegionID);
  319. // create XML sniplet
  320. StringBuilder list = new StringBuilder();
  321. IEntityCountModule entityCountModule = scene.RequestModuleInterface<IEntityCountModule>();
  322. if (entityCountModule != null)
  323. {
  324. list.Append(String.Format("<avatars count=\"{0}\" region_name=\"{1}\" region_uuid=\"{2}\" timestamp=\"{3}\">\n",
  325. entityCountModule.RootAgents, scene.RegionInfo.RegionName,
  326. scene.RegionInfo.RegionID,
  327. DateTime.UtcNow.ToString("s")));
  328. }
  329. scene.ForEachScenePresence(delegate(IScenePresence sp)
  330. {
  331. if (!sp.IsChildAgent)
  332. {
  333. list.Append(String.Format(" <avatar name=\"{0}\" uuid=\"{1}\" />\n", sp.Name, sp.UUID));
  334. list.Append("</avatars>");
  335. }
  336. });
  337. string payload = list.ToString();
  338. // post via REST to broker
  339. HttpWebRequest updatePost = WebRequest.Create(uri) as HttpWebRequest;
  340. updatePost.Method = "POST";
  341. updatePost.ContentType = "text/xml";
  342. updatePost.ContentLength = payload.Length;
  343. updatePost.UserAgent = "OpenSim.Concierge";
  344. BrokerState bs = new BrokerState(uri, payload, updatePost);
  345. bs.Timer = new Timer(delegate(object state)
  346. {
  347. BrokerState b = state as BrokerState;
  348. b.Poster.Abort();
  349. b.Timer.Dispose();
  350. m_log.Debug("[Concierge]: async broker POST abort due to timeout");
  351. }, bs, m_brokerUpdateTimeout * 1000, Timeout.Infinite);
  352. try
  353. {
  354. updatePost.BeginGetRequestStream(UpdateBrokerSend, bs);
  355. m_log.DebugFormat("[Concierge] async broker POST to {0} started", uri);
  356. }
  357. catch (WebException we)
  358. {
  359. m_log.ErrorFormat("[Concierge] async broker POST to {0} failed: {1}", uri, we.Status);
  360. }
  361. }
  362. private void UpdateBrokerSend(IAsyncResult result)
  363. {
  364. BrokerState bs = null;
  365. try
  366. {
  367. bs = result.AsyncState as BrokerState;
  368. string payload = bs.Payload;
  369. HttpWebRequest updatePost = bs.Poster;
  370. using (StreamWriter payloadStream = new StreamWriter(updatePost.EndGetRequestStream(result)))
  371. {
  372. payloadStream.Write(payload);
  373. payloadStream.Close();
  374. }
  375. updatePost.BeginGetResponse(UpdateBrokerDone, bs);
  376. }
  377. catch (WebException we)
  378. {
  379. m_log.DebugFormat("[Concierge]: async broker POST to {0} failed: {1}", bs.Uri, we.Status);
  380. }
  381. catch (Exception)
  382. {
  383. m_log.DebugFormat("[Concierge]: async broker POST to {0} failed", bs.Uri);
  384. }
  385. }
  386. private void UpdateBrokerDone(IAsyncResult result)
  387. {
  388. BrokerState bs = null;
  389. try
  390. {
  391. bs = result.AsyncState as BrokerState;
  392. HttpWebRequest updatePost = bs.Poster;
  393. using (HttpWebResponse response = updatePost.EndGetResponse(result) as HttpWebResponse)
  394. {
  395. m_log.DebugFormat("[Concierge] broker update: status {0}", response.StatusCode);
  396. }
  397. bs.Timer.Dispose();
  398. }
  399. catch (WebException we)
  400. {
  401. m_log.ErrorFormat("[Concierge] broker update to {0} failed with status {1}", bs.Uri, we.Status);
  402. if (null != we.Response)
  403. {
  404. using (HttpWebResponse resp = we.Response as HttpWebResponse)
  405. {
  406. m_log.ErrorFormat("[Concierge] response from {0} status code: {1}", bs.Uri, resp.StatusCode);
  407. m_log.ErrorFormat("[Concierge] response from {0} status desc: {1}", bs.Uri, resp.StatusDescription);
  408. m_log.ErrorFormat("[Concierge] response from {0} server: {1}", bs.Uri, resp.Server);
  409. if (resp.ContentLength > 0)
  410. {
  411. StreamReader content = new StreamReader(resp.GetResponseStream());
  412. m_log.ErrorFormat("[Concierge] response from {0} content: {1}", bs.Uri, content.ReadToEnd());
  413. content.Close();
  414. }
  415. }
  416. }
  417. }
  418. }
  419. protected void WelcomeAvatar (IScenePresence agent, IScene scene)
  420. {
  421. // welcome mechanics: check whether we have a welcomes
  422. // directory set and wether there is a region specific
  423. // welcome file there: if yes, send it to the agent
  424. if (!String.IsNullOrEmpty(m_welcomes))
  425. {
  426. string[] welcomes = new string[] {
  427. Path.Combine(m_welcomes, agent.Scene.RegionInfo.RegionName),
  428. Path.Combine(m_welcomes, "DEFAULT")};
  429. foreach (string welcome in welcomes)
  430. {
  431. if (File.Exists(welcome))
  432. {
  433. try
  434. {
  435. string[] welcomeLines = File.ReadAllLines(welcome);
  436. foreach (string l in welcomeLines)
  437. {
  438. AnnounceToAgent(agent, String.Format(l, agent.Name, scene.RegionInfo.RegionName, m_whoami));
  439. }
  440. }
  441. catch (IOException ioe)
  442. {
  443. m_log.ErrorFormat("[Concierge]: run into trouble reading welcome file {0} for region {1} for avatar {2}: {3}",
  444. welcome, scene.RegionInfo.RegionName, agent.Name, ioe);
  445. }
  446. catch (FormatException fe)
  447. {
  448. m_log.ErrorFormat("[Concierge]: welcome file {0} is malformed: {1}", welcome, fe);
  449. }
  450. }
  451. return;
  452. }
  453. m_log.DebugFormat("[Concierge]: no welcome message for region {0}", scene.RegionInfo.RegionName);
  454. }
  455. }
  456. static private Vector3 PosOfGod = new Vector3(128, 128, 9999);
  457. // protected void AnnounceToAgentsRegion(Scene scene, string msg)
  458. // {
  459. // ScenePresence agent = null;
  460. // if ((client.Scene is Scene) && (client.Scene as Scene).TryGetScenePresence(client.AgentId, out agent))
  461. // AnnounceToAgentsRegion(agent, msg);
  462. // else
  463. // m_log.DebugFormat("[Concierge]: could not find an agent for client {0}", client.Name);
  464. // }
  465. protected void AnnounceToAgentsRegion(IScene scene, string msg)
  466. {
  467. OSChatMessage c = new OSChatMessage();
  468. c.Message = msg;
  469. c.Type = ChatTypeEnum.Say;
  470. c.Channel = 0;
  471. c.Position = PosOfGod;
  472. c.From = m_whoami;
  473. c.Sender = null;
  474. c.SenderUUID = UUID.Zero;
  475. c.Scene = scene;
  476. scene.EventManager.TriggerOnChatBroadcast(this, c);
  477. }
  478. protected void AnnounceToAgent (IScenePresence agent, string msg)
  479. {
  480. OSChatMessage c = new OSChatMessage();
  481. c.Message = msg;
  482. c.Type = ChatTypeEnum.Say;
  483. c.Channel = 0;
  484. c.Position = PosOfGod;
  485. c.From = m_whoami;
  486. c.Sender = null;
  487. c.SenderUUID = UUID.Zero;
  488. c.Scene = agent.Scene;
  489. agent.ControllingClient.SendChatMessage(msg, (byte) ChatTypeEnum.Say, PosOfGod, m_whoami, UUID.Zero,
  490. (byte)ChatSourceType.Object, (byte)ChatAudibleLevel.Fully);
  491. }
  492. private static void checkStringParameters(XmlRpcRequest request, string[] param)
  493. {
  494. Hashtable requestData = (Hashtable) request.Params[0];
  495. foreach (string p in param)
  496. {
  497. if (!requestData.Contains(p))
  498. throw new Exception(String.Format("missing string parameter {0}", p));
  499. if (String.IsNullOrEmpty((string)requestData[p]))
  500. throw new Exception(String.Format("parameter {0} is empty", p));
  501. }
  502. }
  503. public XmlRpcResponse XmlRpcUpdateWelcomeMethod(XmlRpcRequest request, IPEndPoint remoteClient)
  504. {
  505. m_log.Info("[Concierge]: processing UpdateWelcome request");
  506. XmlRpcResponse response = new XmlRpcResponse();
  507. Hashtable responseData = new Hashtable();
  508. try
  509. {
  510. Hashtable requestData = (Hashtable)request.Params[0];
  511. checkStringParameters(request, new string[] { "password", "region", "welcome" });
  512. // check password
  513. if (!String.IsNullOrEmpty(m_xmlRpcPassword) &&
  514. (string)requestData["password"] != m_xmlRpcPassword) throw new Exception("wrong password");
  515. if (String.IsNullOrEmpty(m_welcomes))
  516. throw new Exception("welcome templates are not enabled, ask your OpenSim operator to set the \"welcomes\" option in the [Concierge] section of Aurora.ini");
  517. string msg = (string)requestData["welcome"];
  518. if (String.IsNullOrEmpty(msg))
  519. throw new Exception("empty parameter \"welcome\"");
  520. string regionName = (string)requestData["region"];
  521. IScene scene = m_scenes.Find(delegate(IScene s) { return s.RegionInfo.RegionName == regionName; });
  522. if (scene == null)
  523. throw new Exception(String.Format("unknown region \"{0}\"", regionName));
  524. if (!m_conciergedScenes.Contains(scene))
  525. throw new Exception(String.Format("region \"{0}\" is not a concierged region.", regionName));
  526. string welcome = Path.Combine(m_welcomes, regionName);
  527. if (File.Exists(welcome))
  528. {
  529. m_log.InfoFormat("[Concierge]: UpdateWelcome: updating existing template \"{0}\"", welcome);
  530. string welcomeBackup = String.Format("{0}~", welcome);
  531. if (File.Exists(welcomeBackup))
  532. File.Delete(welcomeBackup);
  533. File.Move(welcome, welcomeBackup);
  534. }
  535. File.WriteAllText(welcome, msg);
  536. responseData["success"] = "true";
  537. response.Value = responseData;
  538. }
  539. catch (Exception e)
  540. {
  541. m_log.InfoFormat("[Concierge]: UpdateWelcome failed: {0}", e.Message);
  542. responseData["success"] = "false";
  543. responseData["error"] = e.Message;
  544. response.Value = responseData;
  545. }
  546. m_log.Debug("[Concierge]: done processing UpdateWelcome request");
  547. return response;
  548. }
  549. }
  550. }