UserProfileModule.cs 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.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 OpenSimulator 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.IO;
  29. using System.Text;
  30. using System.Collections;
  31. using System.Collections.Generic;
  32. using System.Globalization;
  33. using System.Net;
  34. using System.Net.Sockets;
  35. using System.Reflection;
  36. using System.Xml;
  37. using OpenMetaverse;
  38. using OpenMetaverse.StructuredData;
  39. using log4net;
  40. using Nini.Config;
  41. using Nwc.XmlRpc;
  42. using OpenSim.Framework;
  43. using OpenSim.Region.Framework.Interfaces;
  44. using OpenSim.Region.Framework.Scenes;
  45. using OpenSim.Services.Interfaces;
  46. using Mono.Addins;
  47. using OpenSim.Services.Connectors.Hypergrid;
  48. using OpenSim.Framework.Servers.HttpServer;
  49. using OpenSim.Services.UserProfilesService;
  50. using GridRegion = OpenSim.Services.Interfaces.GridRegion;
  51. using Microsoft.CSharp;
  52. namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
  53. {
  54. [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "UserProfilesModule")]
  55. public class UserProfileModule : IProfileModule, INonSharedRegionModule
  56. {
  57. /// <summary>
  58. /// Logging
  59. /// </summary>
  60. static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  61. // The pair of Dictionaries are used to handle the switching of classified ads
  62. // by maintaining a cache of classified id to creator id mappings and an interest
  63. // count. The entries are removed when the interest count reaches 0.
  64. Dictionary<UUID, UUID> m_classifiedCache = new Dictionary<UUID, UUID>();
  65. Dictionary<UUID, int> m_classifiedInterest = new Dictionary<UUID, int>();
  66. private JsonRpcRequestManager rpc = new JsonRpcRequestManager();
  67. public Scene Scene
  68. {
  69. get; private set;
  70. }
  71. /// <summary>
  72. /// Gets or sets the ConfigSource.
  73. /// </summary>
  74. /// <value>
  75. /// The configuration
  76. /// </value>
  77. public IConfigSource Config
  78. {
  79. get;
  80. set;
  81. }
  82. /// <summary>
  83. /// Gets or sets the URI to the profile server.
  84. /// </summary>
  85. /// <value>
  86. /// The profile server URI.
  87. /// </value>
  88. public string ProfileServerUri
  89. {
  90. get;
  91. set;
  92. }
  93. IProfileModule ProfileModule
  94. {
  95. get; set;
  96. }
  97. IUserManagement UserManagementModule
  98. {
  99. get; set;
  100. }
  101. /// <summary>
  102. /// Gets or sets a value indicating whether this
  103. /// <see cref="OpenSim.Region.Coremodules.UserProfiles.UserProfileModule"/> is enabled.
  104. /// </summary>
  105. /// <value>
  106. /// <c>true</c> if enabled; otherwise, <c>false</c>.
  107. /// </value>
  108. public bool Enabled
  109. {
  110. get;
  111. set;
  112. }
  113. public string MyGatekeeper
  114. {
  115. get; private set;
  116. }
  117. #region IRegionModuleBase implementation
  118. /// <summary>
  119. /// This is called to initialize the region module. For shared modules, this is called exactly once, after
  120. /// creating the single (shared) instance. For non-shared modules, this is called once on each instance, after
  121. /// the instace for the region has been created.
  122. /// </summary>
  123. /// <param name='source'>
  124. /// Source.
  125. /// </param>
  126. public void Initialise(IConfigSource source)
  127. {
  128. Config = source;
  129. ReplaceableInterface = typeof(IProfileModule);
  130. IConfig profileConfig = Config.Configs["UserProfiles"];
  131. if (profileConfig == null)
  132. {
  133. m_log.Debug("[PROFILES]: UserProfiles disabled, no configuration");
  134. Enabled = false;
  135. return;
  136. }
  137. // If we find ProfileURL then we configure for FULL support
  138. // else we setup for BASIC support
  139. ProfileServerUri = profileConfig.GetString("ProfileServiceURL", "");
  140. if (ProfileServerUri == "")
  141. {
  142. Enabled = false;
  143. return;
  144. }
  145. m_log.Debug("[PROFILES]: Full Profiles Enabled");
  146. ReplaceableInterface = null;
  147. Enabled = true;
  148. MyGatekeeper = Util.GetConfigVarFromSections<string>(source, "GatekeeperURI",
  149. new string[] { "Startup", "Hypergrid", "UserProfiles" }, String.Empty);
  150. }
  151. /// <summary>
  152. /// Adds the region.
  153. /// </summary>
  154. /// <param name='scene'>
  155. /// Scene.
  156. /// </param>
  157. public void AddRegion(Scene scene)
  158. {
  159. if(!Enabled)
  160. return;
  161. Scene = scene;
  162. Scene.RegisterModuleInterface<IProfileModule>(this);
  163. Scene.EventManager.OnNewClient += OnNewClient;
  164. Scene.EventManager.OnMakeRootAgent += HandleOnMakeRootAgent;
  165. UserManagementModule = Scene.RequestModuleInterface<IUserManagement>();
  166. }
  167. void HandleOnMakeRootAgent (ScenePresence obj)
  168. {
  169. if(obj.PresenceType == PresenceType.Npc)
  170. return;
  171. Util.FireAndForget(delegate
  172. {
  173. GetImageAssets(((IScenePresence)obj).UUID);
  174. }, null, "UserProfileModule.GetImageAssets");
  175. }
  176. /// <summary>
  177. /// Removes the region.
  178. /// </summary>
  179. /// <param name='scene'>
  180. /// Scene.
  181. /// </param>
  182. public void RemoveRegion(Scene scene)
  183. {
  184. if(!Enabled)
  185. return;
  186. }
  187. /// <summary>
  188. /// This will be called once for every scene loaded. In a shared module this will be multiple times in one
  189. /// instance, while a nonshared module instance will only be called once. This method is called after AddRegion
  190. /// has been called in all modules for that scene, providing an opportunity to request another module's
  191. /// interface, or hook an event from another module.
  192. /// </summary>
  193. /// <param name='scene'>
  194. /// Scene.
  195. /// </param>
  196. public void RegionLoaded(Scene scene)
  197. {
  198. if(!Enabled)
  199. return;
  200. }
  201. /// <summary>
  202. /// If this returns non-null, it is the type of an interface that this module intends to register. This will
  203. /// cause the loader to defer loading of this module until all other modules have been loaded. If no other
  204. /// module has registered the interface by then, this module will be activated, else it will remain inactive,
  205. /// letting the other module take over. This should return non-null ONLY in modules that are intended to be
  206. /// easily replaceable, e.g. stub implementations that the developer expects to be replaced by third party
  207. /// provided modules.
  208. /// </summary>
  209. /// <value>
  210. /// The replaceable interface.
  211. /// </value>
  212. public Type ReplaceableInterface
  213. {
  214. get; private set;
  215. }
  216. /// <summary>
  217. /// Called as the instance is closed.
  218. /// </summary>
  219. public void Close()
  220. {
  221. }
  222. /// <value>
  223. /// The name of the module
  224. /// </value>
  225. /// <summary>
  226. /// Gets the module name.
  227. /// </summary>
  228. public string Name
  229. {
  230. get { return "UserProfileModule"; }
  231. }
  232. #endregion IRegionModuleBase implementation
  233. #region Region Event Handlers
  234. /// <summary>
  235. /// Raises the new client event.
  236. /// </summary>
  237. /// <param name='client'>
  238. /// Client.
  239. /// </param>
  240. void OnNewClient(IClientAPI client)
  241. {
  242. //Profile
  243. client.OnRequestAvatarProperties += RequestAvatarProperties;
  244. client.OnUpdateAvatarProperties += AvatarPropertiesUpdate;
  245. client.OnAvatarInterestUpdate += AvatarInterestsUpdate;
  246. // Classifieds
  247. client.AddGenericPacketHandler("avatarclassifiedsrequest", ClassifiedsRequest);
  248. client.OnClassifiedInfoUpdate += ClassifiedInfoUpdate;
  249. client.OnClassifiedInfoRequest += ClassifiedInfoRequest;
  250. client.OnClassifiedDelete += ClassifiedDelete;
  251. // Picks
  252. client.AddGenericPacketHandler("avatarpicksrequest", PicksRequest);
  253. client.AddGenericPacketHandler("pickinforequest", PickInfoRequest);
  254. client.OnPickInfoUpdate += PickInfoUpdate;
  255. client.OnPickDelete += PickDelete;
  256. // Notes
  257. client.AddGenericPacketHandler("avatarnotesrequest", NotesRequest);
  258. client.OnAvatarNotesUpdate += NotesUpdate;
  259. // Preferences
  260. client.OnUserInfoRequest += UserPreferencesRequest;
  261. client.OnUpdateUserInfo += UpdateUserPreferences;
  262. }
  263. #endregion Region Event Handlers
  264. #region Classified
  265. ///
  266. /// <summary>
  267. /// Handles the avatar classifieds request.
  268. /// </summary>
  269. /// <param name='sender'>
  270. /// Sender.
  271. /// </param>
  272. /// <param name='method'>
  273. /// Method.
  274. /// </param>
  275. /// <param name='args'>
  276. /// Arguments.
  277. /// </param>
  278. public void ClassifiedsRequest(Object sender, string method, List<String> args)
  279. {
  280. if (!(sender is IClientAPI))
  281. return;
  282. IClientAPI remoteClient = (IClientAPI)sender;
  283. UUID targetID;
  284. UUID.TryParse(args[0], out targetID);
  285. // Can't handle NPC yet...
  286. ScenePresence p = FindPresence(targetID);
  287. if (null != p)
  288. {
  289. if (p.PresenceType == PresenceType.Npc)
  290. return;
  291. }
  292. string serverURI = string.Empty;
  293. GetUserProfileServerURI(targetID, out serverURI);
  294. UUID creatorId = UUID.Zero;
  295. Dictionary<UUID, string> classifieds = new Dictionary<UUID, string>();
  296. OSDMap parameters= new OSDMap();
  297. UUID.TryParse(args[0], out creatorId);
  298. parameters.Add("creatorId", OSD.FromUUID(creatorId));
  299. OSD Params = (OSD)parameters;
  300. if(!rpc.JsonRpcRequest(ref Params, "avatarclassifiedsrequest", serverURI, UUID.Random().ToString()))
  301. {
  302. remoteClient.SendAvatarClassifiedReply(new UUID(args[0]), classifieds);
  303. return;
  304. }
  305. parameters = (OSDMap)Params;
  306. OSDArray list = (OSDArray)parameters["result"];
  307. foreach(OSD map in list)
  308. {
  309. OSDMap m = (OSDMap)map;
  310. UUID cid = m["classifieduuid"].AsUUID();
  311. string name = m["name"].AsString();
  312. classifieds[cid] = name;
  313. lock (m_classifiedCache)
  314. {
  315. if (!m_classifiedCache.ContainsKey(cid))
  316. {
  317. m_classifiedCache.Add(cid,creatorId);
  318. m_classifiedInterest.Add(cid, 0);
  319. }
  320. m_classifiedInterest[cid]++;
  321. }
  322. }
  323. remoteClient.SendAvatarClassifiedReply(new UUID(args[0]), classifieds);
  324. }
  325. public void ClassifiedInfoRequest(UUID queryClassifiedID, IClientAPI remoteClient)
  326. {
  327. UUID target = remoteClient.AgentId;
  328. UserClassifiedAdd ad = new UserClassifiedAdd();
  329. ad.ClassifiedId = queryClassifiedID;
  330. lock (m_classifiedCache)
  331. {
  332. if (m_classifiedCache.ContainsKey(queryClassifiedID))
  333. {
  334. target = m_classifiedCache[queryClassifiedID];
  335. m_classifiedInterest[queryClassifiedID] --;
  336. if (m_classifiedInterest[queryClassifiedID] == 0)
  337. {
  338. m_classifiedInterest.Remove(queryClassifiedID);
  339. m_classifiedCache.Remove(queryClassifiedID);
  340. }
  341. }
  342. }
  343. string serverURI = string.Empty;
  344. GetUserProfileServerURI(target, out serverURI);
  345. object Ad = (object)ad;
  346. if(!rpc.JsonRpcRequest(ref Ad, "classifieds_info_query", serverURI, UUID.Random().ToString()))
  347. {
  348. remoteClient.SendAgentAlertMessage(
  349. "Error getting classified info", false);
  350. return;
  351. }
  352. ad = (UserClassifiedAdd) Ad;
  353. if(ad.CreatorId == UUID.Zero)
  354. return;
  355. Vector3 globalPos = new Vector3();
  356. Vector3.TryParse(ad.GlobalPos, out globalPos);
  357. remoteClient.SendClassifiedInfoReply(ad.ClassifiedId, ad.CreatorId, (uint)ad.CreationDate, (uint)ad.ExpirationDate,
  358. (uint)ad.Category, ad.Name, ad.Description, ad.ParcelId, (uint)ad.ParentEstate,
  359. ad.SnapshotId, ad.SimName, globalPos, ad.ParcelName, ad.Flags, ad.Price);
  360. }
  361. /// <summary>
  362. /// Classifieds info update.
  363. /// </summary>
  364. /// <param name='queryclassifiedID'>
  365. /// Queryclassified I.
  366. /// </param>
  367. /// <param name='queryCategory'>
  368. /// Query category.
  369. /// </param>
  370. /// <param name='queryName'>
  371. /// Query name.
  372. /// </param>
  373. /// <param name='queryDescription'>
  374. /// Query description.
  375. /// </param>
  376. /// <param name='queryParcelID'>
  377. /// Query parcel I.
  378. /// </param>
  379. /// <param name='queryParentEstate'>
  380. /// Query parent estate.
  381. /// </param>
  382. /// <param name='querySnapshotID'>
  383. /// Query snapshot I.
  384. /// </param>
  385. /// <param name='queryGlobalPos'>
  386. /// Query global position.
  387. /// </param>
  388. /// <param name='queryclassifiedFlags'>
  389. /// Queryclassified flags.
  390. /// </param>
  391. /// <param name='queryclassifiedPrice'>
  392. /// Queryclassified price.
  393. /// </param>
  394. /// <param name='remoteClient'>
  395. /// Remote client.
  396. /// </param>
  397. public void ClassifiedInfoUpdate(UUID queryclassifiedID, uint queryCategory, string queryName, string queryDescription, UUID queryParcelID,
  398. uint queryParentEstate, UUID querySnapshotID, Vector3 queryGlobalPos, byte queryclassifiedFlags,
  399. int queryclassifiedPrice, IClientAPI remoteClient)
  400. {
  401. UserClassifiedAdd ad = new UserClassifiedAdd();
  402. Scene s = (Scene) remoteClient.Scene;
  403. Vector3 pos = remoteClient.SceneAgent.AbsolutePosition;
  404. ILandObject land = s.LandChannel.GetLandObject(pos.X, pos.Y);
  405. ScenePresence p = FindPresence(remoteClient.AgentId);
  406. string serverURI = string.Empty;
  407. GetUserProfileServerURI(remoteClient.AgentId, out serverURI);
  408. if (land == null)
  409. {
  410. ad.ParcelName = string.Empty;
  411. }
  412. else
  413. {
  414. ad.ParcelName = land.LandData.Name;
  415. }
  416. ad.CreatorId = remoteClient.AgentId;
  417. ad.ClassifiedId = queryclassifiedID;
  418. ad.Category = Convert.ToInt32(queryCategory);
  419. ad.Name = queryName;
  420. ad.Description = queryDescription;
  421. ad.ParentEstate = Convert.ToInt32(queryParentEstate);
  422. ad.SnapshotId = querySnapshotID;
  423. ad.SimName = remoteClient.Scene.RegionInfo.RegionName;
  424. ad.GlobalPos = queryGlobalPos.ToString ();
  425. ad.Flags = queryclassifiedFlags;
  426. ad.Price = queryclassifiedPrice;
  427. ad.ParcelId = p.currentParcelUUID;
  428. object Ad = ad;
  429. OSD.SerializeMembers(Ad);
  430. if(!rpc.JsonRpcRequest(ref Ad, "classified_update", serverURI, UUID.Random().ToString()))
  431. {
  432. remoteClient.SendAgentAlertMessage(
  433. "Error updating classified", false);
  434. return;
  435. }
  436. }
  437. /// <summary>
  438. /// Classifieds delete.
  439. /// </summary>
  440. /// <param name='queryClassifiedID'>
  441. /// Query classified I.
  442. /// </param>
  443. /// <param name='remoteClient'>
  444. /// Remote client.
  445. /// </param>
  446. public void ClassifiedDelete(UUID queryClassifiedID, IClientAPI remoteClient)
  447. {
  448. string serverURI = string.Empty;
  449. GetUserProfileServerURI(remoteClient.AgentId, out serverURI);
  450. UUID classifiedId;
  451. OSDMap parameters= new OSDMap();
  452. UUID.TryParse(queryClassifiedID.ToString(), out classifiedId);
  453. parameters.Add("classifiedId", OSD.FromUUID(classifiedId));
  454. OSD Params = (OSD)parameters;
  455. if(!rpc.JsonRpcRequest(ref Params, "classified_delete", serverURI, UUID.Random().ToString()))
  456. {
  457. remoteClient.SendAgentAlertMessage(
  458. "Error classified delete", false);
  459. return;
  460. }
  461. parameters = (OSDMap)Params;
  462. }
  463. #endregion Classified
  464. #region Picks
  465. /// <summary>
  466. /// Handles the avatar picks request.
  467. /// </summary>
  468. /// <param name='sender'>
  469. /// Sender.
  470. /// </param>
  471. /// <param name='method'>
  472. /// Method.
  473. /// </param>
  474. /// <param name='args'>
  475. /// Arguments.
  476. /// </param>
  477. public void PicksRequest(Object sender, string method, List<String> args)
  478. {
  479. if (!(sender is IClientAPI))
  480. return;
  481. IClientAPI remoteClient = (IClientAPI)sender;
  482. UUID targetId;
  483. UUID.TryParse(args[0], out targetId);
  484. // Can't handle NPC yet...
  485. ScenePresence p = FindPresence(targetId);
  486. if (null != p)
  487. {
  488. if (p.PresenceType == PresenceType.Npc)
  489. return;
  490. }
  491. string serverURI = string.Empty;
  492. GetUserProfileServerURI(targetId, out serverURI);
  493. Dictionary<UUID, string> picks = new Dictionary<UUID, string>();
  494. OSDMap parameters= new OSDMap();
  495. parameters.Add("creatorId", OSD.FromUUID(targetId));
  496. OSD Params = (OSD)parameters;
  497. if(!rpc.JsonRpcRequest(ref Params, "avatarpicksrequest", serverURI, UUID.Random().ToString()))
  498. {
  499. remoteClient.SendAvatarPicksReply(new UUID(args[0]), picks);
  500. return;
  501. }
  502. parameters = (OSDMap)Params;
  503. OSDArray list = (OSDArray)parameters["result"];
  504. foreach(OSD map in list)
  505. {
  506. OSDMap m = (OSDMap)map;
  507. UUID cid = m["pickuuid"].AsUUID();
  508. string name = m["name"].AsString();
  509. m_log.DebugFormat("[PROFILES]: PicksRequest {0}", name);
  510. picks[cid] = name;
  511. }
  512. remoteClient.SendAvatarPicksReply(new UUID(args[0]), picks);
  513. }
  514. /// <summary>
  515. /// Handles the pick info request.
  516. /// </summary>
  517. /// <param name='sender'>
  518. /// Sender.
  519. /// </param>
  520. /// <param name='method'>
  521. /// Method.
  522. /// </param>
  523. /// <param name='args'>
  524. /// Arguments.
  525. /// </param>
  526. public void PickInfoRequest(Object sender, string method, List<String> args)
  527. {
  528. if (!(sender is IClientAPI))
  529. return;
  530. UUID targetID;
  531. UUID.TryParse (args [0], out targetID);
  532. string serverURI = string.Empty;
  533. GetUserProfileServerURI (targetID, out serverURI);
  534. string theirGatekeeperURI;
  535. GetUserGatekeeperURI (targetID, out theirGatekeeperURI);
  536. IClientAPI remoteClient = (IClientAPI)sender;
  537. UserProfilePick pick = new UserProfilePick ();
  538. UUID.TryParse (args [0], out pick.CreatorId);
  539. UUID.TryParse (args [1], out pick.PickId);
  540. object Pick = (object)pick;
  541. if (!rpc.JsonRpcRequest (ref Pick, "pickinforequest", serverURI, UUID.Random ().ToString ())) {
  542. remoteClient.SendAgentAlertMessage (
  543. "Error selecting pick", false);
  544. return;
  545. }
  546. pick = (UserProfilePick)Pick;
  547. Vector3 globalPos = new Vector3(Vector3.Zero);
  548. // Smoke and mirrors
  549. if (pick.Gatekeeper == MyGatekeeper)
  550. {
  551. Vector3.TryParse(pick.GlobalPos,out globalPos);
  552. }
  553. else
  554. {
  555. // Setup the illusion
  556. string region = string.Format("{0} {1}",pick.Gatekeeper,pick.SimName);
  557. GridRegion target = Scene.GridService.GetRegionByName(Scene.RegionInfo.ScopeID, region);
  558. if(target == null)
  559. {
  560. // This is a dead or unreachable region
  561. }
  562. else
  563. {
  564. // Work our slight of hand
  565. int x = target.RegionLocX;
  566. int y = target.RegionLocY;
  567. dynamic synthX = globalPos.X - (globalPos.X/Constants.RegionSize) * Constants.RegionSize;
  568. synthX += x;
  569. globalPos.X = synthX;
  570. dynamic synthY = globalPos.Y - (globalPos.Y/Constants.RegionSize) * Constants.RegionSize;
  571. synthY += y;
  572. globalPos.Y = synthY;
  573. }
  574. }
  575. m_log.DebugFormat("[PROFILES]: PickInfoRequest: {0} : {1}", pick.Name.ToString(), pick.SnapshotId.ToString());
  576. // Pull the rabbit out of the hat
  577. remoteClient.SendPickInfoReply(pick.PickId,pick.CreatorId,pick.TopPick,pick.ParcelId,pick.Name,
  578. pick.Desc,pick.SnapshotId,pick.User,pick.OriginalName,pick.SimName,
  579. globalPos,pick.SortOrder,pick.Enabled);
  580. }
  581. /// <summary>
  582. /// Updates the userpicks
  583. /// </summary>
  584. /// <param name='remoteClient'>
  585. /// Remote client.
  586. /// </param>
  587. /// <param name='pickID'>
  588. /// Pick I.
  589. /// </param>
  590. /// <param name='creatorID'>
  591. /// the creator of the pick
  592. /// </param>
  593. /// <param name='topPick'>
  594. /// Top pick.
  595. /// </param>
  596. /// <param name='name'>
  597. /// Name.
  598. /// </param>
  599. /// <param name='desc'>
  600. /// Desc.
  601. /// </param>
  602. /// <param name='snapshotID'>
  603. /// Snapshot I.
  604. /// </param>
  605. /// <param name='sortOrder'>
  606. /// Sort order.
  607. /// </param>
  608. /// <param name='enabled'>
  609. /// Enabled.
  610. /// </param>
  611. public void PickInfoUpdate(IClientAPI remoteClient, UUID pickID, UUID creatorID, bool topPick, string name, string desc, UUID snapshotID, int sortOrder, bool enabled)
  612. {
  613. //TODO: See how this works with NPC, May need to test
  614. m_log.DebugFormat("[PROFILES]: Start PickInfoUpdate Name: {0} PickId: {1} SnapshotId: {2}", name, pickID.ToString(), snapshotID.ToString());
  615. UserProfilePick pick = new UserProfilePick();
  616. string serverURI = string.Empty;
  617. GetUserProfileServerURI(remoteClient.AgentId, out serverURI);
  618. ScenePresence p = FindPresence(remoteClient.AgentId);
  619. Vector3 avaPos = p.AbsolutePosition;
  620. // Getting the global position for the Avatar
  621. Vector3 posGlobal = new Vector3(remoteClient.Scene.RegionInfo.WorldLocX + avaPos.X,
  622. remoteClient.Scene.RegionInfo.WorldLocY + avaPos.Y,
  623. avaPos.Z);
  624. string landOwnerName = string.Empty;
  625. ILandObject land = p.Scene.LandChannel.GetLandObject(avaPos.X, avaPos.Y);
  626. if (land != null)
  627. {
  628. if (land.LandData.IsGroupOwned)
  629. {
  630. IGroupsModule groupMod = p.Scene.RequestModuleInterface<IGroupsModule>();
  631. UUID groupId = land.LandData.GroupID;
  632. GroupRecord groupRecord = groupMod.GetGroupRecord(groupId);
  633. landOwnerName = groupRecord.GroupName;
  634. }
  635. else
  636. {
  637. IUserAccountService accounts = p.Scene.RequestModuleInterface<IUserAccountService>();
  638. UserAccount user = accounts.GetUserAccount(p.Scene.RegionInfo.ScopeID, land.LandData.OwnerID);
  639. landOwnerName = user.Name;
  640. }
  641. }
  642. else
  643. {
  644. m_log.WarnFormat(
  645. "[PROFILES]: PickInfoUpdate found no parcel info at {0},{1} in {2}",
  646. avaPos.X, avaPos.Y, p.Scene.Name);
  647. }
  648. pick.PickId = pickID;
  649. pick.CreatorId = creatorID;
  650. pick.TopPick = topPick;
  651. pick.Name = name;
  652. pick.Desc = desc;
  653. pick.ParcelId = p.currentParcelUUID;
  654. pick.SnapshotId = snapshotID;
  655. pick.User = landOwnerName;
  656. pick.SimName = remoteClient.Scene.RegionInfo.RegionName;
  657. pick.Gatekeeper = MyGatekeeper;
  658. pick.GlobalPos = posGlobal.ToString();
  659. pick.SortOrder = sortOrder;
  660. pick.Enabled = enabled;
  661. object Pick = (object)pick;
  662. if(!rpc.JsonRpcRequest(ref Pick, "picks_update", serverURI, UUID.Random().ToString()))
  663. {
  664. remoteClient.SendAgentAlertMessage(
  665. "Error updating pick", false);
  666. return;
  667. }
  668. m_log.DebugFormat("[PROFILES]: Finish PickInfoUpdate {0} {1}", pick.Name, pick.PickId.ToString());
  669. }
  670. /// <summary>
  671. /// Delete a Pick
  672. /// </summary>
  673. /// <param name='remoteClient'>
  674. /// Remote client.
  675. /// </param>
  676. /// <param name='queryPickID'>
  677. /// Query pick I.
  678. /// </param>
  679. public void PickDelete(IClientAPI remoteClient, UUID queryPickID)
  680. {
  681. string serverURI = string.Empty;
  682. GetUserProfileServerURI(remoteClient.AgentId, out serverURI);
  683. OSDMap parameters= new OSDMap();
  684. parameters.Add("pickId", OSD.FromUUID(queryPickID));
  685. OSD Params = (OSD)parameters;
  686. if(!rpc.JsonRpcRequest(ref Params, "picks_delete", serverURI, UUID.Random().ToString()))
  687. {
  688. remoteClient.SendAgentAlertMessage(
  689. "Error picks delete", false);
  690. return;
  691. }
  692. }
  693. #endregion Picks
  694. #region Notes
  695. /// <summary>
  696. /// Handles the avatar notes request.
  697. /// </summary>
  698. /// <param name='sender'>
  699. /// Sender.
  700. /// </param>
  701. /// <param name='method'>
  702. /// Method.
  703. /// </param>
  704. /// <param name='args'>
  705. /// Arguments.
  706. /// </param>
  707. public void NotesRequest(Object sender, string method, List<String> args)
  708. {
  709. UserProfileNotes note = new UserProfileNotes();
  710. if (!(sender is IClientAPI))
  711. return;
  712. IClientAPI remoteClient = (IClientAPI)sender;
  713. string serverURI = string.Empty;
  714. GetUserProfileServerURI(remoteClient.AgentId, out serverURI);
  715. note.UserId = remoteClient.AgentId;
  716. UUID.TryParse(args[0], out note.TargetId);
  717. object Note = (object)note;
  718. if(!rpc.JsonRpcRequest(ref Note, "avatarnotesrequest", serverURI, UUID.Random().ToString()))
  719. {
  720. remoteClient.SendAvatarNotesReply(note.TargetId, note.Notes);
  721. return;
  722. }
  723. note = (UserProfileNotes) Note;
  724. remoteClient.SendAvatarNotesReply(note.TargetId, note.Notes);
  725. }
  726. /// <summary>
  727. /// Avatars the notes update.
  728. /// </summary>
  729. /// <param name='remoteClient'>
  730. /// Remote client.
  731. /// </param>
  732. /// <param name='queryTargetID'>
  733. /// Query target I.
  734. /// </param>
  735. /// <param name='queryNotes'>
  736. /// Query notes.
  737. /// </param>
  738. public void NotesUpdate(IClientAPI remoteClient, UUID queryTargetID, string queryNotes)
  739. {
  740. UserProfileNotes note = new UserProfileNotes();
  741. note.UserId = remoteClient.AgentId;
  742. note.TargetId = queryTargetID;
  743. note.Notes = queryNotes;
  744. string serverURI = string.Empty;
  745. GetUserProfileServerURI(remoteClient.AgentId, out serverURI);
  746. object Note = note;
  747. if(!rpc.JsonRpcRequest(ref Note, "avatar_notes_update", serverURI, UUID.Random().ToString()))
  748. {
  749. remoteClient.SendAgentAlertMessage(
  750. "Error updating note", false);
  751. return;
  752. }
  753. }
  754. #endregion Notes
  755. #region User Preferences
  756. /// <summary>
  757. /// Updates the user preferences.
  758. /// </summary>
  759. /// <param name='imViaEmail'>
  760. /// Im via email.
  761. /// </param>
  762. /// <param name='visible'>
  763. /// Visible.
  764. /// </param>
  765. /// <param name='remoteClient'>
  766. /// Remote client.
  767. /// </param>
  768. public void UpdateUserPreferences(bool imViaEmail, bool visible, IClientAPI remoteClient)
  769. {
  770. UserPreferences pref = new UserPreferences();
  771. pref.UserId = remoteClient.AgentId;
  772. pref.IMViaEmail = imViaEmail;
  773. pref.Visible = visible;
  774. string serverURI = string.Empty;
  775. bool foreign = GetUserProfileServerURI(remoteClient.AgentId, out serverURI);
  776. object Pref = pref;
  777. if(!rpc.JsonRpcRequest(ref Pref, "user_preferences_update", serverURI, UUID.Random().ToString()))
  778. {
  779. m_log.InfoFormat("[PROFILES]: UserPreferences update error");
  780. remoteClient.SendAgentAlertMessage("Error updating preferences", false);
  781. return;
  782. }
  783. }
  784. /// <summary>
  785. /// Users the preferences request.
  786. /// </summary>
  787. /// <param name='remoteClient'>
  788. /// Remote client.
  789. /// </param>
  790. public void UserPreferencesRequest(IClientAPI remoteClient)
  791. {
  792. UserPreferences pref = new UserPreferences();
  793. pref.UserId = remoteClient.AgentId;
  794. string serverURI = string.Empty;
  795. bool foreign = GetUserProfileServerURI(remoteClient.AgentId, out serverURI);
  796. object Pref = (object)pref;
  797. if(!rpc.JsonRpcRequest(ref Pref, "user_preferences_request", serverURI, UUID.Random().ToString()))
  798. {
  799. // m_log.InfoFormat("[PROFILES]: UserPreferences request error");
  800. // remoteClient.SendAgentAlertMessage("Error requesting preferences", false);
  801. return;
  802. }
  803. pref = (UserPreferences) Pref;
  804. remoteClient.SendUserInfoReply(pref.IMViaEmail, pref.Visible, pref.EMail);
  805. }
  806. #endregion User Preferences
  807. #region Avatar Properties
  808. /// <summary>
  809. /// Update the avatars interests .
  810. /// </summary>
  811. /// <param name='remoteClient'>
  812. /// Remote client.
  813. /// </param>
  814. /// <param name='wantmask'>
  815. /// Wantmask.
  816. /// </param>
  817. /// <param name='wanttext'>
  818. /// Wanttext.
  819. /// </param>
  820. /// <param name='skillsmask'>
  821. /// Skillsmask.
  822. /// </param>
  823. /// <param name='skillstext'>
  824. /// Skillstext.
  825. /// </param>
  826. /// <param name='languages'>
  827. /// Languages.
  828. /// </param>
  829. public void AvatarInterestsUpdate(IClientAPI remoteClient, uint wantmask, string wanttext, uint skillsmask, string skillstext, string languages)
  830. {
  831. UserProfileProperties prop = new UserProfileProperties();
  832. prop.UserId = remoteClient.AgentId;
  833. prop.WantToMask = (int)wantmask;
  834. prop.WantToText = wanttext;
  835. prop.SkillsMask = (int)skillsmask;
  836. prop.SkillsText = skillstext;
  837. prop.Language = languages;
  838. string serverURI = string.Empty;
  839. GetUserProfileServerURI(remoteClient.AgentId, out serverURI);
  840. object Param = prop;
  841. if(!rpc.JsonRpcRequest(ref Param, "avatar_interests_update", serverURI, UUID.Random().ToString()))
  842. {
  843. remoteClient.SendAgentAlertMessage(
  844. "Error updating interests", false);
  845. return;
  846. }
  847. }
  848. public void RequestAvatarProperties(IClientAPI remoteClient, UUID avatarID)
  849. {
  850. if (String.IsNullOrEmpty(avatarID.ToString()) || String.IsNullOrEmpty(remoteClient.AgentId.ToString()))
  851. {
  852. // Looking for a reason that some viewers are sending null Id's
  853. m_log.DebugFormat("[PROFILES]: This should not happen remoteClient.AgentId {0} - avatarID {1}", remoteClient.AgentId, avatarID);
  854. return;
  855. }
  856. // Can't handle NPC yet...
  857. ScenePresence p = FindPresence(avatarID);
  858. if (null != p)
  859. {
  860. if (p.PresenceType == PresenceType.Npc)
  861. return;
  862. }
  863. string serverURI = string.Empty;
  864. bool foreign = GetUserProfileServerURI(avatarID, out serverURI);
  865. UserAccount account = null;
  866. Dictionary<string,object> userInfo;
  867. if (!foreign)
  868. {
  869. account = Scene.UserAccountService.GetUserAccount(Scene.RegionInfo.ScopeID, avatarID);
  870. }
  871. else
  872. {
  873. userInfo = new Dictionary<string, object>();
  874. }
  875. Byte[] charterMember = new Byte[1];
  876. string born = String.Empty;
  877. uint flags = 0x00;
  878. if (null != account)
  879. {
  880. if (account.UserTitle == "")
  881. {
  882. charterMember[0] = (Byte)((account.UserFlags & 0xf00) >> 8);
  883. }
  884. else
  885. {
  886. charterMember = Utils.StringToBytes(account.UserTitle);
  887. }
  888. born = Util.ToDateTime(account.Created).ToString(
  889. "M/d/yyyy", CultureInfo.InvariantCulture);
  890. flags = (uint)(account.UserFlags & 0xff);
  891. }
  892. else
  893. {
  894. if (GetUserAccountData(avatarID, out userInfo) == true)
  895. {
  896. if ((string)userInfo["user_title"] == "")
  897. {
  898. charterMember[0] = (Byte)(((Byte)userInfo["user_flags"] & 0xf00) >> 8);
  899. }
  900. else
  901. {
  902. charterMember = Utils.StringToBytes((string)userInfo["user_title"]);
  903. }
  904. int val_born = (int)userInfo["user_created"];
  905. born = Util.ToDateTime(val_born).ToString(
  906. "M/d/yyyy", CultureInfo.InvariantCulture);
  907. // picky, picky
  908. int val_flags = (int)userInfo["user_flags"];
  909. flags = (uint)(val_flags & 0xff);
  910. }
  911. }
  912. UserProfileProperties props = new UserProfileProperties();
  913. string result = string.Empty;
  914. props.UserId = avatarID;
  915. if (!GetProfileData(ref props, foreign, out result))
  916. {
  917. // m_log.DebugFormat("Error getting profile for {0}: {1}", avatarID, result);
  918. return;
  919. }
  920. remoteClient.SendAvatarProperties(props.UserId, props.AboutText, born, charterMember , props.FirstLifeText, flags,
  921. props.FirstLifeImageId, props.ImageId, props.WebUrl, props.PartnerId);
  922. remoteClient.SendAvatarInterestsReply(props.UserId, (uint)props.WantToMask, props.WantToText, (uint)props.SkillsMask,
  923. props.SkillsText, props.Language);
  924. }
  925. /// <summary>
  926. /// Updates the avatar properties.
  927. /// </summary>
  928. /// <param name='remoteClient'>
  929. /// Remote client.
  930. /// </param>
  931. /// <param name='newProfile'>
  932. /// New profile.
  933. /// </param>
  934. public void AvatarPropertiesUpdate(IClientAPI remoteClient, UserProfileData newProfile)
  935. {
  936. if (remoteClient.AgentId == newProfile.ID)
  937. {
  938. UserProfileProperties prop = new UserProfileProperties();
  939. prop.UserId = remoteClient.AgentId;
  940. prop.WebUrl = newProfile.ProfileUrl;
  941. prop.ImageId = newProfile.Image;
  942. prop.AboutText = newProfile.AboutText;
  943. prop.FirstLifeImageId = newProfile.FirstLifeImage;
  944. prop.FirstLifeText = newProfile.FirstLifeAboutText;
  945. string serverURI = string.Empty;
  946. GetUserProfileServerURI(remoteClient.AgentId, out serverURI);
  947. object Prop = prop;
  948. if(!rpc.JsonRpcRequest(ref Prop, "avatar_properties_update", serverURI, UUID.Random().ToString()))
  949. {
  950. remoteClient.SendAgentAlertMessage(
  951. "Error updating properties", false);
  952. return;
  953. }
  954. RequestAvatarProperties(remoteClient, newProfile.ID);
  955. }
  956. }
  957. /// <summary>
  958. /// Gets the profile data.
  959. /// </summary>
  960. /// <returns>
  961. /// The profile data.
  962. /// </returns>
  963. bool GetProfileData(ref UserProfileProperties properties, bool foreign, out string message)
  964. {
  965. // Can't handle NPC yet...
  966. ScenePresence p = FindPresence(properties.UserId);
  967. if (null != p)
  968. {
  969. if (p.PresenceType == PresenceType.Npc)
  970. {
  971. message = "Id points to NPC";
  972. return false;
  973. }
  974. }
  975. string serverURI = string.Empty;
  976. GetUserProfileServerURI(properties.UserId, out serverURI);
  977. // This is checking a friend on the home grid
  978. // Not HG friend
  979. if (String.IsNullOrEmpty(serverURI))
  980. {
  981. message = "No Presence - foreign friend";
  982. return false;
  983. }
  984. object Prop = (object)properties;
  985. if (!rpc.JsonRpcRequest(ref Prop, "avatar_properties_request", serverURI, UUID.Random().ToString()))
  986. {
  987. // If it's a foreign user then try again using OpenProfile, in case that's what the grid is using
  988. bool secondChanceSuccess = false;
  989. if (foreign)
  990. {
  991. try
  992. {
  993. OpenProfileClient client = new OpenProfileClient(serverURI);
  994. if (client.RequestAvatarPropertiesUsingOpenProfile(ref properties))
  995. secondChanceSuccess = true;
  996. }
  997. catch (Exception e)
  998. {
  999. m_log.Debug(
  1000. string.Format(
  1001. "[PROFILES]: Request using the OpenProfile API for user {0} to {1} failed",
  1002. properties.UserId, serverURI),
  1003. e);
  1004. // Allow the return 'message' to say "JsonRpcRequest" and not "OpenProfile", because
  1005. // the most likely reason that OpenProfile failed is that the remote server
  1006. // doesn't support OpenProfile, and that's not very interesting.
  1007. }
  1008. }
  1009. if (!secondChanceSuccess)
  1010. {
  1011. message = string.Format("JsonRpcRequest for user {0} to {1} failed", properties.UserId, serverURI);
  1012. m_log.DebugFormat("[PROFILES]: {0}", message);
  1013. return false;
  1014. }
  1015. // else, continue below
  1016. }
  1017. properties = (UserProfileProperties)Prop;
  1018. message = "Success";
  1019. return true;
  1020. }
  1021. #endregion Avatar Properties
  1022. #region Utils
  1023. bool GetImageAssets(UUID avatarId)
  1024. {
  1025. string profileServerURI = string.Empty;
  1026. string assetServerURI = string.Empty;
  1027. bool foreign = GetUserProfileServerURI(avatarId, out profileServerURI);
  1028. if(!foreign)
  1029. return true;
  1030. assetServerURI = UserManagementModule.GetUserServerURL(avatarId, "AssetServerURI");
  1031. if(string.IsNullOrEmpty(profileServerURI) || string.IsNullOrEmpty(assetServerURI))
  1032. return false;
  1033. OSDMap parameters= new OSDMap();
  1034. parameters.Add("avatarId", OSD.FromUUID(avatarId));
  1035. OSD Params = (OSD)parameters;
  1036. if(!rpc.JsonRpcRequest(ref Params, "image_assets_request", profileServerURI, UUID.Random().ToString()))
  1037. {
  1038. return false;
  1039. }
  1040. parameters = (OSDMap)Params;
  1041. if (parameters.ContainsKey("result"))
  1042. {
  1043. OSDArray list = (OSDArray)parameters["result"];
  1044. foreach (OSD asset in list)
  1045. {
  1046. OSDString assetId = (OSDString)asset;
  1047. Scene.AssetService.Get(string.Format("{0}/{1}", assetServerURI, assetId.AsString()));
  1048. }
  1049. return true;
  1050. }
  1051. else
  1052. {
  1053. m_log.ErrorFormat("[PROFILES]: Problematic response for image_assets_request from {0}", profileServerURI);
  1054. return false;
  1055. }
  1056. }
  1057. /// <summary>
  1058. /// Gets the user account data.
  1059. /// </summary>
  1060. /// <returns>
  1061. /// The user profile data.
  1062. /// </returns>
  1063. /// <param name='userID'>
  1064. /// If set to <c>true</c> user I.
  1065. /// </param>
  1066. /// <param name='userInfo'>
  1067. /// If set to <c>true</c> user info.
  1068. /// </param>
  1069. bool GetUserAccountData(UUID userID, out Dictionary<string, object> userInfo)
  1070. {
  1071. Dictionary<string,object> info = new Dictionary<string, object>();
  1072. if (UserManagementModule.IsLocalGridUser(userID))
  1073. {
  1074. // Is local
  1075. IUserAccountService uas = Scene.UserAccountService;
  1076. UserAccount account = uas.GetUserAccount(Scene.RegionInfo.ScopeID, userID);
  1077. info["user_flags"] = account.UserFlags;
  1078. info["user_created"] = account.Created;
  1079. if (!String.IsNullOrEmpty(account.UserTitle))
  1080. info["user_title"] = account.UserTitle;
  1081. else
  1082. info["user_title"] = "";
  1083. userInfo = info;
  1084. return false;
  1085. }
  1086. else
  1087. {
  1088. // Is Foreign
  1089. string home_url = UserManagementModule.GetUserServerURL(userID, "HomeURI");
  1090. if (String.IsNullOrEmpty(home_url))
  1091. {
  1092. info["user_flags"] = 0;
  1093. info["user_created"] = 0;
  1094. info["user_title"] = "Unavailable";
  1095. userInfo = info;
  1096. return true;
  1097. }
  1098. UserAgentServiceConnector uConn = new UserAgentServiceConnector(home_url);
  1099. Dictionary<string, object> account;
  1100. try
  1101. {
  1102. account = uConn.GetUserInfo(userID);
  1103. }
  1104. catch (Exception e)
  1105. {
  1106. m_log.Debug("[PROFILES]: GetUserInfo call failed ", e);
  1107. account = new Dictionary<string, object>();
  1108. }
  1109. if (account.Count > 0)
  1110. {
  1111. if (account.ContainsKey("user_flags"))
  1112. info["user_flags"] = account["user_flags"];
  1113. else
  1114. info["user_flags"] = "";
  1115. if (account.ContainsKey("user_created"))
  1116. info["user_created"] = account["user_created"];
  1117. else
  1118. info["user_created"] = "";
  1119. info["user_title"] = "HG Visitor";
  1120. }
  1121. else
  1122. {
  1123. info["user_flags"] = 0;
  1124. info["user_created"] = 0;
  1125. info["user_title"] = "HG Visitor";
  1126. }
  1127. userInfo = info;
  1128. return true;
  1129. }
  1130. }
  1131. /// <summary>
  1132. /// Gets the user gatekeeper server URI.
  1133. /// </summary>
  1134. /// <returns>
  1135. /// The user gatekeeper server URI.
  1136. /// </returns>
  1137. /// <param name='userID'>
  1138. /// If set to <c>true</c> user URI.
  1139. /// </param>
  1140. /// <param name='serverURI'>
  1141. /// If set to <c>true</c> server URI.
  1142. /// </param>
  1143. bool GetUserGatekeeperURI(UUID userID, out string serverURI)
  1144. {
  1145. bool local;
  1146. local = UserManagementModule.IsLocalGridUser(userID);
  1147. if (!local)
  1148. {
  1149. serverURI = UserManagementModule.GetUserServerURL(userID, "GatekeeperURI");
  1150. // Is Foreign
  1151. return true;
  1152. }
  1153. else
  1154. {
  1155. serverURI = MyGatekeeper;
  1156. // Is local
  1157. return false;
  1158. }
  1159. }
  1160. /// <summary>
  1161. /// Gets the user profile server UR.
  1162. /// </summary>
  1163. /// <returns>
  1164. /// The user profile server UR.
  1165. /// </returns>
  1166. /// <param name='userID'>
  1167. /// If set to <c>true</c> user I.
  1168. /// </param>
  1169. /// <param name='serverURI'>
  1170. /// If set to <c>true</c> server UR.
  1171. /// </param>
  1172. bool GetUserProfileServerURI(UUID userID, out string serverURI)
  1173. {
  1174. bool local;
  1175. local = UserManagementModule.IsLocalGridUser(userID);
  1176. if (!local)
  1177. {
  1178. serverURI = UserManagementModule.GetUserServerURL(userID, "ProfileServerURI");
  1179. // Is Foreign
  1180. return true;
  1181. }
  1182. else
  1183. {
  1184. serverURI = ProfileServerUri;
  1185. // Is local
  1186. return false;
  1187. }
  1188. }
  1189. /// <summary>
  1190. /// Finds the presence.
  1191. /// </summary>
  1192. /// <returns>
  1193. /// The presence.
  1194. /// </returns>
  1195. /// <param name='clientID'>
  1196. /// Client I.
  1197. /// </param>
  1198. ScenePresence FindPresence(UUID clientID)
  1199. {
  1200. ScenePresence p;
  1201. p = Scene.GetScenePresence(clientID);
  1202. if (p != null && !p.IsChildAgent)
  1203. return p;
  1204. return null;
  1205. }
  1206. #endregion Util
  1207. }
  1208. }