PageRenderTime 52ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/OpenSimProfile/Modules/ProfileModule/OpenProfile.cs

https://bitbucket.org/VirtualReality/optional-modules
C# | 740 lines | 524 code | 151 blank | 65 comment | 72 complexity | 305f84d0b5d06c2e8014758414aa5b64 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.Globalization;
  31. using System.Net;
  32. using System.Net.Sockets;
  33. using System.Reflection;
  34. using System.Xml;
  35. using OpenMetaverse;
  36. using log4net;
  37. using Nini.Config;
  38. using Nwc.XmlRpc;
  39. using Aurora.Framework;
  40. using OpenSim.Region.Framework.Interfaces;
  41. using OpenSim.Region.Framework.Scenes;
  42. using OpenSim.Services.Interfaces;
  43. namespace OpenSimProfile.Modules.OpenProfile
  44. {
  45. public class OpenProfileModule : ISharedRegionModule
  46. {
  47. //
  48. // Log module
  49. //
  50. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  51. //
  52. // Module vars
  53. //
  54. private IConfigSource m_gConfig;
  55. private List<IScene> m_Scenes = new List<IScene>();
  56. private string m_ProfileServer = "";
  57. private bool m_Enabled = true;
  58. public void Initialise(IConfigSource source)
  59. {
  60. m_gConfig = source;
  61. IConfig profileConfig = source.Configs["Profile"];
  62. if (profileConfig == null)
  63. {
  64. m_Enabled = false;
  65. return;
  66. }
  67. m_ProfileServer = profileConfig.GetString("ProfileURL", "");
  68. if (m_ProfileServer == "")
  69. {
  70. m_Enabled = false;
  71. return;
  72. }
  73. else
  74. {
  75. m_log.Info("[PROFILE] OpenProfile module is activated");
  76. m_Enabled = true;
  77. }
  78. }
  79. public void PostInitialise()
  80. {
  81. }
  82. public void Close()
  83. {
  84. }
  85. public string Name
  86. {
  87. get { return "ProfileModule"; }
  88. }
  89. public Type ReplaceableInterface
  90. {
  91. get { return null; }
  92. }
  93. public void AddRegion(IScene scene)
  94. {
  95. if (!m_Enabled)
  96. return;
  97. m_Scenes.Add(scene);
  98. // Hook up events
  99. scene.EventManager.OnNewClient += OnNewClient;
  100. }
  101. public void RemoveRegion(IScene scene)
  102. {
  103. m_Scenes.Remove(scene);
  104. scene.EventManager.OnNewClient -= OnNewClient;
  105. }
  106. public void RegionLoaded(IScene scene)
  107. {
  108. }
  109. IScenePresence FindPresence(UUID clientID)
  110. {
  111. IScenePresence p;
  112. foreach (IScene s in m_Scenes)
  113. {
  114. p = s.GetScenePresence(clientID);
  115. if (p != null && !p.IsChildAgent)
  116. return p;
  117. }
  118. return null;
  119. }
  120. /// New Client Event Handler
  121. private void OnNewClient(IClientAPI client)
  122. {
  123. // Subscribe to messages
  124. // Classifieds
  125. client.AddGenericPacketHandler("avatarclassifiedsrequest", HandleAvatarClassifiedsRequest);
  126. client.OnClassifiedInfoUpdate += ClassifiedInfoUpdate;
  127. client.OnClassifiedDelete += ClassifiedDelete;
  128. // Picks
  129. client.AddGenericPacketHandler("avatarpicksrequest", HandleAvatarPicksRequest);
  130. client.AddGenericPacketHandler("pickinforequest", HandlePickInfoRequest);
  131. client.OnPickInfoUpdate += PickInfoUpdate;
  132. client.OnPickDelete += PickDelete;
  133. // Notes
  134. client.AddGenericPacketHandler("avatarnotesrequest", HandleAvatarNotesRequest);
  135. client.OnAvatarNotesUpdate += AvatarNotesUpdate;
  136. //Profile
  137. client.OnRequestAvatarProperties += RequestAvatarProperties;
  138. client.OnUpdateAvatarProperties += UpdateAvatarProperties;
  139. client.OnAvatarInterestUpdate += AvatarInterestsUpdate;
  140. client.OnUserInfoRequest += UserPreferencesRequest;
  141. client.OnUpdateUserInfo += UpdateUserPreferences;
  142. }
  143. //
  144. // Make external XMLRPC request
  145. //
  146. private Hashtable GenericXMLRPCRequest(Hashtable ReqParams, string method)
  147. {
  148. ArrayList SendParams = new ArrayList();
  149. SendParams.Add(ReqParams);
  150. // Send Request
  151. XmlRpcResponse Resp;
  152. try
  153. {
  154. XmlRpcRequest Req = new XmlRpcRequest(method, SendParams);
  155. Resp = Req.Send(m_ProfileServer, 30000);
  156. }
  157. catch (WebException ex)
  158. {
  159. m_log.ErrorFormat("[PROFILE]: Unable to connect to Profile " +
  160. "Server {0}. Exception {1}", m_ProfileServer, ex);
  161. Hashtable ErrorHash = new Hashtable();
  162. ErrorHash["success"] = false;
  163. ErrorHash["errorMessage"] = "Unable to fetch profile data at this time. ";
  164. ErrorHash["errorURI"] = "";
  165. return ErrorHash;
  166. }
  167. catch (SocketException ex)
  168. {
  169. m_log.ErrorFormat(
  170. "[PROFILE]: Unable to connect to Profile Server {0}. Method {1}, params {2}. " +
  171. "Exception {3}", m_ProfileServer, method, ReqParams, ex);
  172. Hashtable ErrorHash = new Hashtable();
  173. ErrorHash["success"] = false;
  174. ErrorHash["errorMessage"] = "Unable to fetch profile data at this time. ";
  175. ErrorHash["errorURI"] = "";
  176. return ErrorHash;
  177. }
  178. catch (XmlException ex)
  179. {
  180. m_log.ErrorFormat(
  181. "[PROFILE]: Unable to connect to Profile Server {0}. Method {1}, params {2}. " +
  182. "Exception {3}", m_ProfileServer, method, ReqParams.ToString(), ex);
  183. Hashtable ErrorHash = new Hashtable();
  184. ErrorHash["success"] = false;
  185. ErrorHash["errorMessage"] = "Unable to fetch profile data at this time. ";
  186. ErrorHash["errorURI"] = "";
  187. return ErrorHash;
  188. }
  189. if (Resp.IsFault)
  190. {
  191. Hashtable ErrorHash = new Hashtable();
  192. ErrorHash["success"] = false;
  193. ErrorHash["errorMessage"] = "Unable to fetch profile data at this time. ";
  194. ErrorHash["errorURI"] = "";
  195. return ErrorHash;
  196. }
  197. Hashtable RespData = (Hashtable)Resp.Value;
  198. return RespData;
  199. }
  200. // Classifieds Handler
  201. public void HandleAvatarClassifiedsRequest(Object sender, string method, List<String> args)
  202. {
  203. if (!(sender is IClientAPI))
  204. return;
  205. IClientAPI remoteClient = (IClientAPI)sender;
  206. Hashtable ReqHash = new Hashtable();
  207. ReqHash["uuid"] = args[0];
  208. Hashtable result = GenericXMLRPCRequest(ReqHash,
  209. method);
  210. if (!Convert.ToBoolean(result["success"]))
  211. {
  212. remoteClient.SendAgentAlertMessage(
  213. result["errorMessage"].ToString(), false);
  214. return;
  215. }
  216. ArrayList dataArray = (ArrayList)result["data"];
  217. Dictionary<UUID, string> classifieds = new Dictionary<UUID, string>();
  218. foreach (Object o in dataArray)
  219. {
  220. Hashtable d = (Hashtable)o;
  221. classifieds[new UUID(d["classifiedid"].ToString())] = d["name"].ToString();
  222. }
  223. remoteClient.SendAvatarClassifiedReply(new UUID(args[0]), classifieds);
  224. }
  225. // Classifieds Update
  226. public void ClassifiedInfoUpdate(UUID queryclassifiedID, uint queryCategory, string queryName, string queryDescription, UUID queryParcelID,
  227. uint queryParentEstate, UUID querySnapshotID, Vector3 queryGlobalPos, byte queryclassifiedFlags,
  228. int queryclassifiedPrice, IClientAPI remoteClient)
  229. {
  230. Hashtable ReqHash = new Hashtable();
  231. ReqHash["creatorUUID"] = remoteClient.AgentId.ToString();
  232. ReqHash["classifiedUUID"] = queryclassifiedID.ToString();
  233. ReqHash["category"] = queryCategory.ToString();
  234. ReqHash["name"] = queryName;
  235. ReqHash["description"] = queryDescription;
  236. ReqHash["parentestate"] = queryParentEstate.ToString();
  237. ReqHash["snapshotUUID"] = querySnapshotID.ToString();
  238. ReqHash["sim_name"] = remoteClient.Scene.RegionInfo.RegionName;
  239. ReqHash["globalpos"] = queryGlobalPos.ToString();
  240. ReqHash["classifiedFlags"] = queryclassifiedFlags.ToString();
  241. ReqHash["classifiedPrice"] = queryclassifiedPrice.ToString();
  242. IScenePresence p = FindPresence(remoteClient.AgentId);
  243. Vector3 avaPos = p.AbsolutePosition;
  244. // Getting the parceluuid for this parcel
  245. ReqHash["parcel_uuid"] = p.CurrentParcelUUID.ToString();
  246. // Getting the global position for the Avatar
  247. Vector3 posGlobal = new Vector3(remoteClient.Scene.RegionInfo.RegionLocX + avaPos.X,
  248. remoteClient.Scene.RegionInfo.RegionLocY + avaPos.Y,
  249. avaPos.Z);
  250. ReqHash["pos_global"] = posGlobal.ToString();
  251. Hashtable result = GenericXMLRPCRequest(ReqHash,
  252. "classified_update");
  253. if (!Convert.ToBoolean(result["success"]))
  254. {
  255. remoteClient.SendAgentAlertMessage(
  256. result["errorMessage"].ToString(), false);
  257. }
  258. }
  259. // Classifieds Delete
  260. public void ClassifiedDelete(UUID queryClassifiedID, IClientAPI remoteClient)
  261. {
  262. Hashtable ReqHash = new Hashtable();
  263. ReqHash["classifiedID"] = queryClassifiedID.ToString();
  264. Hashtable result = GenericXMLRPCRequest(ReqHash,
  265. "classified_delete");
  266. if (!Convert.ToBoolean(result["success"]))
  267. {
  268. remoteClient.SendAgentAlertMessage(
  269. result["errorMessage"].ToString(), false);
  270. }
  271. }
  272. // Picks Handler
  273. public void HandleAvatarPicksRequest(Object sender, string method, List<String> args)
  274. {
  275. if (!(sender is IClientAPI))
  276. return;
  277. IClientAPI remoteClient = (IClientAPI)sender;
  278. Hashtable ReqHash = new Hashtable();
  279. ReqHash["uuid"] = args[0];
  280. Hashtable result = GenericXMLRPCRequest(ReqHash,
  281. method);
  282. if (!Convert.ToBoolean(result["success"]))
  283. {
  284. remoteClient.SendAgentAlertMessage(
  285. result["errorMessage"].ToString(), false);
  286. return;
  287. }
  288. ArrayList dataArray = (ArrayList)result["data"];
  289. Dictionary<UUID, string> picks = new Dictionary<UUID, string>();
  290. if (dataArray != null)
  291. {
  292. foreach (Object o in dataArray)
  293. {
  294. Hashtable d = (Hashtable)o;
  295. picks[new UUID(d["pickid"].ToString())] = d["name"].ToString();
  296. }
  297. }
  298. remoteClient.SendAvatarPicksReply(new UUID(args[0]), picks);
  299. }
  300. // Picks Request
  301. public void HandlePickInfoRequest(Object sender, string method, List<String> args)
  302. {
  303. if (!(sender is IClientAPI))
  304. return;
  305. IClientAPI remoteClient = (IClientAPI)sender;
  306. Hashtable ReqHash = new Hashtable();
  307. ReqHash["avatar_id"] = args[0];
  308. ReqHash["pick_id"] = args[1];
  309. Hashtable result = GenericXMLRPCRequest(ReqHash,
  310. method);
  311. if (!Convert.ToBoolean(result["success"]))
  312. {
  313. remoteClient.SendAgentAlertMessage(
  314. result["errorMessage"].ToString(), false);
  315. return;
  316. }
  317. ArrayList dataArray = (ArrayList)result["data"];
  318. Hashtable d = (Hashtable)dataArray[0];
  319. Vector3 globalPos = new Vector3();
  320. Vector3.TryParse(d["posglobal"].ToString(), out globalPos);
  321. if (d["description"] == null)
  322. d["description"] = String.Empty;
  323. remoteClient.SendPickInfoReply(
  324. new UUID(d["pickuuid"].ToString()),
  325. new UUID(d["creatoruuid"].ToString()),
  326. Convert.ToBoolean(d["toppick"]),
  327. new UUID(d["parceluuid"].ToString()),
  328. d["name"].ToString(),
  329. d["description"].ToString(),
  330. new UUID(d["snapshotuuid"].ToString()),
  331. d["user"].ToString(),
  332. d["originalname"].ToString(),
  333. d["simname"].ToString(),
  334. globalPos,
  335. Convert.ToInt32(d["sortorder"]),
  336. Convert.ToBoolean(d["enabled"]));
  337. }
  338. // Picks Update
  339. public void PickInfoUpdate(IClientAPI remoteClient, UUID pickID, UUID creatorID, bool topPick, string name, string desc, UUID snapshotID, int sortOrder, bool enabled, Vector3d globalPos)
  340. {
  341. Hashtable ReqHash = new Hashtable();
  342. ReqHash["agent_id"] = remoteClient.AgentId.ToString();
  343. ReqHash["pick_id"] = pickID.ToString();
  344. ReqHash["creator_id"] = creatorID.ToString();
  345. ReqHash["top_pick"] = topPick.ToString();
  346. ReqHash["name"] = name;
  347. ReqHash["desc"] = desc;
  348. ReqHash["snapshot_id"] = snapshotID.ToString();
  349. ReqHash["sort_order"] = sortOrder.ToString();
  350. ReqHash["enabled"] = enabled.ToString();
  351. ReqHash["sim_name"] = remoteClient.Scene.RegionInfo.RegionName;
  352. IScenePresence p = FindPresence(remoteClient.AgentId);
  353. Vector3 avaPos = p.AbsolutePosition;
  354. // Getting the parceluuid for this parcel
  355. ReqHash["parcel_uuid"] = p.CurrentParcelUUID.ToString();
  356. // Getting the global position for the Avatar
  357. Vector3 posGlobal = new Vector3(remoteClient.Scene.RegionInfo.RegionLocX + avaPos.X,
  358. remoteClient.Scene.RegionInfo.RegionLocY + avaPos.Y,
  359. avaPos.Z);
  360. ReqHash["pos_global"] = posGlobal.ToString();
  361. // Getting the owner of the parcel
  362. ReqHash["user"] = ""; //FIXME: Get avatar/group who owns parcel
  363. // Do the request
  364. Hashtable result = GenericXMLRPCRequest(ReqHash,
  365. "picks_update");
  366. if (!Convert.ToBoolean(result["success"]))
  367. {
  368. remoteClient.SendAgentAlertMessage(
  369. result["errorMessage"].ToString(), false);
  370. }
  371. }
  372. // Picks Delete
  373. public void PickDelete(IClientAPI remoteClient, UUID queryPickID)
  374. {
  375. Hashtable ReqHash = new Hashtable();
  376. ReqHash["pick_id"] = queryPickID.ToString();
  377. Hashtable result = GenericXMLRPCRequest(ReqHash,
  378. "picks_delete");
  379. if (!Convert.ToBoolean(result["success"]))
  380. {
  381. remoteClient.SendAgentAlertMessage(
  382. result["errorMessage"].ToString(), false);
  383. }
  384. }
  385. // Notes Handler
  386. public void HandleAvatarNotesRequest(Object sender, string method, List<String> args)
  387. {
  388. string targetid;
  389. string notes = "";
  390. if (!(sender is IClientAPI))
  391. return;
  392. IClientAPI remoteClient = (IClientAPI)sender;
  393. Hashtable ReqHash = new Hashtable();
  394. ReqHash["avatar_id"] = remoteClient.AgentId.ToString();
  395. ReqHash["uuid"] = args[0];
  396. Hashtable result = GenericXMLRPCRequest(ReqHash,
  397. method);
  398. if (!Convert.ToBoolean(result["success"]))
  399. {
  400. remoteClient.SendAgentAlertMessage(
  401. result["errorMessage"].ToString(), false);
  402. return;
  403. }
  404. ArrayList dataArray = (ArrayList)result["data"];
  405. if (dataArray != null && dataArray[0] != null)
  406. {
  407. Hashtable d = (Hashtable)dataArray[0];
  408. targetid = d["targetid"].ToString();
  409. if (d["notes"] != null)
  410. notes = d["notes"].ToString();
  411. remoteClient.SendAvatarNotesReply(new UUID(targetid), notes);
  412. }
  413. }
  414. // Notes Update
  415. public void AvatarNotesUpdate(IClientAPI remoteClient, UUID queryTargetID, string queryNotes)
  416. {
  417. Hashtable ReqHash = new Hashtable();
  418. ReqHash["avatar_id"] = remoteClient.AgentId.ToString();
  419. ReqHash["target_id"] = queryTargetID.ToString();
  420. ReqHash["notes"] = queryNotes;
  421. Hashtable result = GenericXMLRPCRequest(ReqHash,
  422. "avatar_notes_update");
  423. if (!Convert.ToBoolean(result["success"]))
  424. {
  425. remoteClient.SendAgentAlertMessage(
  426. result["errorMessage"].ToString(), false);
  427. }
  428. }
  429. // Standard Profile bits
  430. public void AvatarInterestsUpdate(IClientAPI remoteClient, uint wantmask, string wanttext, uint skillsmask, string skillstext, string languages)
  431. {
  432. Hashtable ReqHash = new Hashtable();
  433. ReqHash["avatar_id"] = remoteClient.AgentId.ToString();
  434. ReqHash["wantmask"] = wantmask.ToString();
  435. ReqHash["wanttext"] = wanttext;
  436. ReqHash["skillsmask"] = skillsmask.ToString();
  437. ReqHash["skillstext"] = skillstext;
  438. ReqHash["languages"] = languages;
  439. Hashtable result = GenericXMLRPCRequest(ReqHash,
  440. "avatar_interests_update");
  441. if (!Convert.ToBoolean(result["success"]))
  442. {
  443. remoteClient.SendAgentAlertMessage(
  444. result["errorMessage"].ToString(), false);
  445. }
  446. }
  447. public void UserPreferencesRequest(IClientAPI remoteClient)
  448. {
  449. Hashtable ReqHash = new Hashtable();
  450. ReqHash["avatar_id"] = remoteClient.AgentId.ToString();
  451. Hashtable result = GenericXMLRPCRequest(ReqHash,
  452. "user_preferences_request");
  453. if (!Convert.ToBoolean(result["success"]))
  454. {
  455. remoteClient.SendAgentAlertMessage(
  456. result["errorMessage"].ToString(), false);
  457. return;
  458. }
  459. ArrayList dataArray = (ArrayList)result["data"];
  460. if (dataArray != null && dataArray[0] != null)
  461. {
  462. Hashtable d = (Hashtable)dataArray[0];
  463. string mail = "";
  464. if (d["email"] != null)
  465. mail = d["email"].ToString();
  466. remoteClient.SendUserInfoReply(
  467. Convert.ToBoolean(d["imviaemail"]),
  468. Convert.ToBoolean(d["visible"]),
  469. mail);
  470. }
  471. }
  472. public void UpdateUserPreferences(bool imViaEmail, bool visible, IClientAPI remoteClient)
  473. {
  474. Hashtable ReqHash = new Hashtable();
  475. ReqHash["avatar_id"] = remoteClient.AgentId.ToString();
  476. ReqHash["imViaEmail"] = imViaEmail.ToString();
  477. ReqHash["visible"] = visible.ToString();
  478. Hashtable result = GenericXMLRPCRequest(ReqHash,
  479. "user_preferences_update");
  480. if (!Convert.ToBoolean(result["success"]))
  481. {
  482. remoteClient.SendAgentAlertMessage(
  483. result["errorMessage"].ToString(), false);
  484. }
  485. }
  486. // Profile data like the WebURL
  487. private Hashtable GetProfileData(UUID userID)
  488. {
  489. Hashtable ReqHash = new Hashtable();
  490. ReqHash["avatar_id"] = userID.ToString();
  491. Hashtable result = GenericXMLRPCRequest(ReqHash,
  492. "avatar_properties_request");
  493. ArrayList dataArray = (ArrayList)result["data"];
  494. if (dataArray != null && dataArray[0] != null)
  495. {
  496. Hashtable d = (Hashtable)dataArray[0];
  497. return d;
  498. }
  499. return result;
  500. }
  501. public void RequestAvatarProperties(IClientAPI remoteClient, UUID avatarID)
  502. {
  503. IScene scene = remoteClient.Scene;
  504. UserAccount account = scene.UserAccountService.GetUserAccount(null, avatarID);
  505. if (null != account)
  506. {
  507. Byte[] charterMember;
  508. if (account.UserTitle == "")
  509. {
  510. charterMember = new Byte[1];
  511. charterMember[0] = (Byte)((account.UserFlags & 0xf00) >> 8);
  512. }
  513. else
  514. {
  515. charterMember = Utils.StringToBytes(account.UserTitle);
  516. }
  517. Hashtable profileData = GetProfileData(avatarID);
  518. string profileUrl = String.Empty;
  519. string aboutText = String.Empty;
  520. string firstLifeAboutText = String.Empty;
  521. UUID image = UUID.Zero;
  522. UUID firstLifeImage = UUID.Zero;
  523. UUID partner = UUID.Zero;
  524. uint wantMask = 0;
  525. string wantText = String.Empty;
  526. uint skillsMask = 0;
  527. string skillsText = String.Empty;
  528. string languages = String.Empty;
  529. if (profileData["ProfileUrl"] != null)
  530. profileUrl = profileData["ProfileUrl"].ToString();
  531. if (profileData["AboutText"] != null)
  532. aboutText = profileData["AboutText"].ToString();
  533. if (profileData["FirstLifeAboutText"] != null)
  534. firstLifeAboutText = profileData["FirstLifeAboutText"].ToString();
  535. if (profileData["Image"] != null)
  536. image = new UUID(profileData["Image"].ToString());
  537. if (profileData["FirstLifeImage"] != null)
  538. firstLifeImage = new UUID(profileData["FirstLifeImage"].ToString());
  539. if (profileData["Partner"] != null)
  540. partner = new UUID(profileData["Partner"].ToString());
  541. // The PROFILE information is no longer stored in the user
  542. // account. It now needs to be taken from the XMLRPC
  543. //
  544. remoteClient.SendAvatarProperties(avatarID, aboutText,
  545. Util.ToDateTime(account.Created).ToString(
  546. "M/d/yyyy", CultureInfo.InvariantCulture),
  547. charterMember, firstLifeAboutText,
  548. (uint)(account.UserFlags & 0xff),
  549. firstLifeImage, image, profileUrl, partner);
  550. //Viewer expects interest data when it asks for properties.
  551. if (profileData["wantmask"] != null)
  552. wantMask = Convert.ToUInt32(profileData["wantmask"].ToString());
  553. if (profileData["wanttext"] != null)
  554. wantText = profileData["wanttext"].ToString();
  555. if (profileData["skillsmask"] != null)
  556. skillsMask = Convert.ToUInt32(profileData["skillsmask"].ToString());
  557. if (profileData["skillstext"] != null)
  558. skillsText = profileData["skillstext"].ToString();
  559. if (profileData["languages"] != null)
  560. languages = profileData["languages"].ToString();
  561. remoteClient.SendAvatarInterestsReply(avatarID, wantMask, wantText,
  562. skillsMask, skillsText, languages);
  563. }
  564. else
  565. {
  566. m_log.Debug("[AvatarProfilesModule]: Got null for profile for " + avatarID.ToString());
  567. }
  568. }
  569. public void UpdateAvatarProperties(IClientAPI remoteClient, string AboutText, string FLAboutText, UUID FLImageID, UUID ImageID, string WebProfileURL, bool allowpublish, bool maturepublish)
  570. {
  571. // if it's the profile of the user requesting the update, then we change only a few things.
  572. Hashtable ReqHash = new Hashtable();
  573. ReqHash["avatar_id"] = remoteClient.AgentId.ToString();
  574. ReqHash["ProfileUrl"] = WebProfileURL;
  575. ReqHash["Image"] = ImageID.ToString();
  576. ReqHash["AboutText"] = AboutText;
  577. ReqHash["FirstLifeImage"] = FLImageID.ToString();
  578. ReqHash["FirstLifeAboutText"] = FLAboutText;
  579. Hashtable result = GenericXMLRPCRequest(ReqHash,
  580. "avatar_properties_update");
  581. if (!Convert.ToBoolean(result["success"]))
  582. {
  583. remoteClient.SendAgentAlertMessage(
  584. result["errorMessage"].ToString(), false);
  585. }
  586. RequestAvatarProperties(remoteClient, remoteClient.AgentId);
  587. }
  588. }
  589. }