UserProfileModule.cs 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406
  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. Scene s = (Scene)remoteClient.Scene;
  402. IMoneyModule money = s.RequestModuleInterface<IMoneyModule>();
  403. if (money != null)
  404. {
  405. if (!money.AmountCovered(remoteClient.AgentId, queryclassifiedPrice))
  406. {
  407. remoteClient.SendAgentAlertMessage("You do not have enough money to create requested classified.", false);
  408. return;
  409. }
  410. money.ApplyCharge(remoteClient.AgentId, queryclassifiedPrice, MoneyTransactionType.ClassifiedCharge);
  411. }
  412. UserClassifiedAdd ad = new UserClassifiedAdd();
  413. Vector3 pos = remoteClient.SceneAgent.AbsolutePosition;
  414. ILandObject land = s.LandChannel.GetLandObject(pos.X, pos.Y);
  415. ScenePresence p = FindPresence(remoteClient.AgentId);
  416. string serverURI = string.Empty;
  417. GetUserProfileServerURI(remoteClient.AgentId, out serverURI);
  418. if (land == null)
  419. {
  420. ad.ParcelName = string.Empty;
  421. }
  422. else
  423. {
  424. ad.ParcelName = land.LandData.Name;
  425. }
  426. ad.CreatorId = remoteClient.AgentId;
  427. ad.ClassifiedId = queryclassifiedID;
  428. ad.Category = Convert.ToInt32(queryCategory);
  429. ad.Name = queryName;
  430. ad.Description = queryDescription;
  431. ad.ParentEstate = Convert.ToInt32(queryParentEstate);
  432. ad.SnapshotId = querySnapshotID;
  433. ad.SimName = remoteClient.Scene.RegionInfo.RegionName;
  434. ad.GlobalPos = queryGlobalPos.ToString ();
  435. ad.Flags = queryclassifiedFlags;
  436. ad.Price = queryclassifiedPrice;
  437. ad.ParcelId = p.currentParcelUUID;
  438. object Ad = ad;
  439. OSD.SerializeMembers(Ad);
  440. if(!rpc.JsonRpcRequest(ref Ad, "classified_update", serverURI, UUID.Random().ToString()))
  441. {
  442. remoteClient.SendAgentAlertMessage(
  443. "Error updating classified", false);
  444. return;
  445. }
  446. }
  447. /// <summary>
  448. /// Classifieds delete.
  449. /// </summary>
  450. /// <param name='queryClassifiedID'>
  451. /// Query classified I.
  452. /// </param>
  453. /// <param name='remoteClient'>
  454. /// Remote client.
  455. /// </param>
  456. public void ClassifiedDelete(UUID queryClassifiedID, IClientAPI remoteClient)
  457. {
  458. string serverURI = string.Empty;
  459. GetUserProfileServerURI(remoteClient.AgentId, out serverURI);
  460. UUID classifiedId;
  461. OSDMap parameters= new OSDMap();
  462. UUID.TryParse(queryClassifiedID.ToString(), out classifiedId);
  463. parameters.Add("classifiedId", OSD.FromUUID(classifiedId));
  464. OSD Params = (OSD)parameters;
  465. if(!rpc.JsonRpcRequest(ref Params, "classified_delete", serverURI, UUID.Random().ToString()))
  466. {
  467. remoteClient.SendAgentAlertMessage(
  468. "Error classified delete", false);
  469. return;
  470. }
  471. parameters = (OSDMap)Params;
  472. }
  473. #endregion Classified
  474. #region Picks
  475. /// <summary>
  476. /// Handles the avatar picks request.
  477. /// </summary>
  478. /// <param name='sender'>
  479. /// Sender.
  480. /// </param>
  481. /// <param name='method'>
  482. /// Method.
  483. /// </param>
  484. /// <param name='args'>
  485. /// Arguments.
  486. /// </param>
  487. public void PicksRequest(Object sender, string method, List<String> args)
  488. {
  489. if (!(sender is IClientAPI))
  490. return;
  491. IClientAPI remoteClient = (IClientAPI)sender;
  492. UUID targetId;
  493. UUID.TryParse(args[0], out targetId);
  494. // Can't handle NPC yet...
  495. ScenePresence p = FindPresence(targetId);
  496. if (null != p)
  497. {
  498. if (p.PresenceType == PresenceType.Npc)
  499. return;
  500. }
  501. string serverURI = string.Empty;
  502. GetUserProfileServerURI(targetId, out serverURI);
  503. Dictionary<UUID, string> picks = new Dictionary<UUID, string>();
  504. OSDMap parameters= new OSDMap();
  505. parameters.Add("creatorId", OSD.FromUUID(targetId));
  506. OSD Params = (OSD)parameters;
  507. if(!rpc.JsonRpcRequest(ref Params, "avatarpicksrequest", serverURI, UUID.Random().ToString()))
  508. {
  509. remoteClient.SendAvatarPicksReply(new UUID(args[0]), picks);
  510. return;
  511. }
  512. parameters = (OSDMap)Params;
  513. OSDArray list = (OSDArray)parameters["result"];
  514. foreach(OSD map in list)
  515. {
  516. OSDMap m = (OSDMap)map;
  517. UUID cid = m["pickuuid"].AsUUID();
  518. string name = m["name"].AsString();
  519. m_log.DebugFormat("[PROFILES]: PicksRequest {0}", name);
  520. picks[cid] = name;
  521. }
  522. remoteClient.SendAvatarPicksReply(new UUID(args[0]), picks);
  523. }
  524. /// <summary>
  525. /// Handles the pick info request.
  526. /// </summary>
  527. /// <param name='sender'>
  528. /// Sender.
  529. /// </param>
  530. /// <param name='method'>
  531. /// Method.
  532. /// </param>
  533. /// <param name='args'>
  534. /// Arguments.
  535. /// </param>
  536. public void PickInfoRequest(Object sender, string method, List<String> args)
  537. {
  538. if (!(sender is IClientAPI))
  539. return;
  540. UUID targetID;
  541. UUID.TryParse (args [0], out targetID);
  542. string serverURI = string.Empty;
  543. GetUserProfileServerURI (targetID, out serverURI);
  544. string theirGatekeeperURI;
  545. GetUserGatekeeperURI (targetID, out theirGatekeeperURI);
  546. IClientAPI remoteClient = (IClientAPI)sender;
  547. UserProfilePick pick = new UserProfilePick ();
  548. UUID.TryParse (args [0], out pick.CreatorId);
  549. UUID.TryParse (args [1], out pick.PickId);
  550. object Pick = (object)pick;
  551. if (!rpc.JsonRpcRequest (ref Pick, "pickinforequest", serverURI, UUID.Random ().ToString ())) {
  552. remoteClient.SendAgentAlertMessage (
  553. "Error selecting pick", false);
  554. return;
  555. }
  556. pick = (UserProfilePick)Pick;
  557. Vector3 globalPos = new Vector3(Vector3.Zero);
  558. // Smoke and mirrors
  559. if (pick.Gatekeeper == MyGatekeeper)
  560. {
  561. Vector3.TryParse(pick.GlobalPos,out globalPos);
  562. }
  563. else
  564. {
  565. // Setup the illusion
  566. string region = string.Format("{0} {1}",pick.Gatekeeper,pick.SimName);
  567. GridRegion target = Scene.GridService.GetRegionByName(Scene.RegionInfo.ScopeID, region);
  568. if(target == null)
  569. {
  570. // This is a dead or unreachable region
  571. }
  572. else
  573. {
  574. // Work our slight of hand
  575. int x = target.RegionLocX;
  576. int y = target.RegionLocY;
  577. dynamic synthX = globalPos.X - (globalPos.X/Constants.RegionSize) * Constants.RegionSize;
  578. synthX += x;
  579. globalPos.X = synthX;
  580. dynamic synthY = globalPos.Y - (globalPos.Y/Constants.RegionSize) * Constants.RegionSize;
  581. synthY += y;
  582. globalPos.Y = synthY;
  583. }
  584. }
  585. m_log.DebugFormat("[PROFILES]: PickInfoRequest: {0} : {1}", pick.Name.ToString(), pick.SnapshotId.ToString());
  586. // Pull the rabbit out of the hat
  587. remoteClient.SendPickInfoReply(pick.PickId,pick.CreatorId,pick.TopPick,pick.ParcelId,pick.Name,
  588. pick.Desc,pick.SnapshotId,pick.ParcelName,pick.OriginalName,pick.SimName,
  589. globalPos,pick.SortOrder,pick.Enabled);
  590. }
  591. /// <summary>
  592. /// Updates the userpicks
  593. /// </summary>
  594. /// <param name='remoteClient'>
  595. /// Remote client.
  596. /// </param>
  597. /// <param name='pickID'>
  598. /// Pick I.
  599. /// </param>
  600. /// <param name='creatorID'>
  601. /// the creator of the pick
  602. /// </param>
  603. /// <param name='topPick'>
  604. /// Top pick.
  605. /// </param>
  606. /// <param name='name'>
  607. /// Name.
  608. /// </param>
  609. /// <param name='desc'>
  610. /// Desc.
  611. /// </param>
  612. /// <param name='snapshotID'>
  613. /// Snapshot I.
  614. /// </param>
  615. /// <param name='sortOrder'>
  616. /// Sort order.
  617. /// </param>
  618. /// <param name='enabled'>
  619. /// Enabled.
  620. /// </param>
  621. public void PickInfoUpdate(IClientAPI remoteClient, UUID pickID, UUID creatorID, bool topPick, string name, string desc, UUID snapshotID, int sortOrder, bool enabled)
  622. {
  623. //TODO: See how this works with NPC, May need to test
  624. m_log.DebugFormat("[PROFILES]: Start PickInfoUpdate Name: {0} PickId: {1} SnapshotId: {2}", name, pickID.ToString(), snapshotID.ToString());
  625. UserProfilePick pick = new UserProfilePick();
  626. string serverURI = string.Empty;
  627. GetUserProfileServerURI(remoteClient.AgentId, out serverURI);
  628. ScenePresence p = FindPresence(remoteClient.AgentId);
  629. Vector3 avaPos = p.AbsolutePosition;
  630. // Getting the global position for the Avatar
  631. Vector3 posGlobal = new Vector3(remoteClient.Scene.RegionInfo.WorldLocX + avaPos.X,
  632. remoteClient.Scene.RegionInfo.WorldLocY + avaPos.Y,
  633. avaPos.Z);
  634. string landParcelName = "My Parcel";
  635. UUID landParcelID = p.currentParcelUUID;
  636. ILandObject land = p.Scene.LandChannel.GetLandObject(avaPos.X, avaPos.Y);
  637. if (land != null)
  638. {
  639. // If land found, use parcel uuid from here because the value from SP will be blank if the avatar hasnt moved
  640. landParcelName = land.LandData.Name;
  641. landParcelID = land.LandData.GlobalID;
  642. }
  643. else
  644. {
  645. m_log.WarnFormat(
  646. "[PROFILES]: PickInfoUpdate found no parcel info at {0},{1} in {2}",
  647. avaPos.X, avaPos.Y, p.Scene.Name);
  648. }
  649. pick.PickId = pickID;
  650. pick.CreatorId = creatorID;
  651. pick.TopPick = topPick;
  652. pick.Name = name;
  653. pick.Desc = desc;
  654. pick.ParcelId = landParcelID;
  655. pick.SnapshotId = snapshotID;
  656. pick.ParcelName = landParcelName;
  657. pick.SimName = remoteClient.Scene.RegionInfo.RegionName;
  658. pick.Gatekeeper = MyGatekeeper;
  659. pick.GlobalPos = posGlobal.ToString();
  660. pick.SortOrder = sortOrder;
  661. pick.Enabled = enabled;
  662. object Pick = (object)pick;
  663. if(!rpc.JsonRpcRequest(ref Pick, "picks_update", serverURI, UUID.Random().ToString()))
  664. {
  665. remoteClient.SendAgentAlertMessage(
  666. "Error updating pick", false);
  667. return;
  668. }
  669. m_log.DebugFormat("[PROFILES]: Finish PickInfoUpdate {0} {1}", pick.Name, pick.PickId.ToString());
  670. }
  671. /// <summary>
  672. /// Delete a Pick
  673. /// </summary>
  674. /// <param name='remoteClient'>
  675. /// Remote client.
  676. /// </param>
  677. /// <param name='queryPickID'>
  678. /// Query pick I.
  679. /// </param>
  680. public void PickDelete(IClientAPI remoteClient, UUID queryPickID)
  681. {
  682. string serverURI = string.Empty;
  683. GetUserProfileServerURI(remoteClient.AgentId, out serverURI);
  684. OSDMap parameters= new OSDMap();
  685. parameters.Add("pickId", OSD.FromUUID(queryPickID));
  686. OSD Params = (OSD)parameters;
  687. if(!rpc.JsonRpcRequest(ref Params, "picks_delete", serverURI, UUID.Random().ToString()))
  688. {
  689. remoteClient.SendAgentAlertMessage(
  690. "Error picks delete", false);
  691. return;
  692. }
  693. }
  694. #endregion Picks
  695. #region Notes
  696. /// <summary>
  697. /// Handles the avatar notes request.
  698. /// </summary>
  699. /// <param name='sender'>
  700. /// Sender.
  701. /// </param>
  702. /// <param name='method'>
  703. /// Method.
  704. /// </param>
  705. /// <param name='args'>
  706. /// Arguments.
  707. /// </param>
  708. public void NotesRequest(Object sender, string method, List<String> args)
  709. {
  710. UserProfileNotes note = new UserProfileNotes();
  711. if (!(sender is IClientAPI))
  712. return;
  713. IClientAPI remoteClient = (IClientAPI)sender;
  714. string serverURI = string.Empty;
  715. GetUserProfileServerURI(remoteClient.AgentId, out serverURI);
  716. note.UserId = remoteClient.AgentId;
  717. UUID.TryParse(args[0], out note.TargetId);
  718. object Note = (object)note;
  719. if(!rpc.JsonRpcRequest(ref Note, "avatarnotesrequest", serverURI, UUID.Random().ToString()))
  720. {
  721. remoteClient.SendAvatarNotesReply(note.TargetId, note.Notes);
  722. return;
  723. }
  724. note = (UserProfileNotes) Note;
  725. remoteClient.SendAvatarNotesReply(note.TargetId, note.Notes);
  726. }
  727. /// <summary>
  728. /// Avatars the notes update.
  729. /// </summary>
  730. /// <param name='remoteClient'>
  731. /// Remote client.
  732. /// </param>
  733. /// <param name='queryTargetID'>
  734. /// Query target I.
  735. /// </param>
  736. /// <param name='queryNotes'>
  737. /// Query notes.
  738. /// </param>
  739. public void NotesUpdate(IClientAPI remoteClient, UUID queryTargetID, string queryNotes)
  740. {
  741. UserProfileNotes note = new UserProfileNotes();
  742. note.UserId = remoteClient.AgentId;
  743. note.TargetId = queryTargetID;
  744. note.Notes = queryNotes;
  745. string serverURI = string.Empty;
  746. GetUserProfileServerURI(remoteClient.AgentId, out serverURI);
  747. object Note = note;
  748. if(!rpc.JsonRpcRequest(ref Note, "avatar_notes_update", serverURI, UUID.Random().ToString()))
  749. {
  750. remoteClient.SendAgentAlertMessage(
  751. "Error updating note", false);
  752. return;
  753. }
  754. }
  755. #endregion Notes
  756. #region User Preferences
  757. /// <summary>
  758. /// Updates the user preferences.
  759. /// </summary>
  760. /// <param name='imViaEmail'>
  761. /// Im via email.
  762. /// </param>
  763. /// <param name='visible'>
  764. /// Visible.
  765. /// </param>
  766. /// <param name='remoteClient'>
  767. /// Remote client.
  768. /// </param>
  769. public void UpdateUserPreferences(bool imViaEmail, bool visible, IClientAPI remoteClient)
  770. {
  771. UserPreferences pref = new UserPreferences();
  772. pref.UserId = remoteClient.AgentId;
  773. pref.IMViaEmail = imViaEmail;
  774. pref.Visible = visible;
  775. string serverURI = string.Empty;
  776. bool foreign = GetUserProfileServerURI(remoteClient.AgentId, out serverURI);
  777. object Pref = pref;
  778. if(!rpc.JsonRpcRequest(ref Pref, "user_preferences_update", serverURI, UUID.Random().ToString()))
  779. {
  780. m_log.InfoFormat("[PROFILES]: UserPreferences update error");
  781. remoteClient.SendAgentAlertMessage("Error updating preferences", false);
  782. return;
  783. }
  784. }
  785. /// <summary>
  786. /// Users the preferences request.
  787. /// </summary>
  788. /// <param name='remoteClient'>
  789. /// Remote client.
  790. /// </param>
  791. public void UserPreferencesRequest(IClientAPI remoteClient)
  792. {
  793. UserPreferences pref = new UserPreferences();
  794. pref.UserId = remoteClient.AgentId;
  795. string serverURI = string.Empty;
  796. bool foreign = GetUserProfileServerURI(remoteClient.AgentId, out serverURI);
  797. object Pref = (object)pref;
  798. if(!rpc.JsonRpcRequest(ref Pref, "user_preferences_request", serverURI, UUID.Random().ToString()))
  799. {
  800. // m_log.InfoFormat("[PROFILES]: UserPreferences request error");
  801. // remoteClient.SendAgentAlertMessage("Error requesting preferences", false);
  802. return;
  803. }
  804. pref = (UserPreferences) Pref;
  805. remoteClient.SendUserInfoReply(pref.IMViaEmail, pref.Visible, pref.EMail);
  806. }
  807. #endregion User Preferences
  808. #region Avatar Properties
  809. /// <summary>
  810. /// Update the avatars interests .
  811. /// </summary>
  812. /// <param name='remoteClient'>
  813. /// Remote client.
  814. /// </param>
  815. /// <param name='wantmask'>
  816. /// Wantmask.
  817. /// </param>
  818. /// <param name='wanttext'>
  819. /// Wanttext.
  820. /// </param>
  821. /// <param name='skillsmask'>
  822. /// Skillsmask.
  823. /// </param>
  824. /// <param name='skillstext'>
  825. /// Skillstext.
  826. /// </param>
  827. /// <param name='languages'>
  828. /// Languages.
  829. /// </param>
  830. public void AvatarInterestsUpdate(IClientAPI remoteClient, uint wantmask, string wanttext, uint skillsmask, string skillstext, string languages)
  831. {
  832. UserProfileProperties prop = new UserProfileProperties();
  833. prop.UserId = remoteClient.AgentId;
  834. prop.WantToMask = (int)wantmask;
  835. prop.WantToText = wanttext;
  836. prop.SkillsMask = (int)skillsmask;
  837. prop.SkillsText = skillstext;
  838. prop.Language = languages;
  839. string serverURI = string.Empty;
  840. GetUserProfileServerURI(remoteClient.AgentId, out serverURI);
  841. object Param = prop;
  842. if(!rpc.JsonRpcRequest(ref Param, "avatar_interests_update", serverURI, UUID.Random().ToString()))
  843. {
  844. remoteClient.SendAgentAlertMessage(
  845. "Error updating interests", false);
  846. return;
  847. }
  848. }
  849. public void RequestAvatarProperties(IClientAPI remoteClient, UUID avatarID)
  850. {
  851. if (String.IsNullOrEmpty(avatarID.ToString()) || String.IsNullOrEmpty(remoteClient.AgentId.ToString()))
  852. {
  853. // Looking for a reason that some viewers are sending null Id's
  854. m_log.DebugFormat("[PROFILES]: This should not happen remoteClient.AgentId {0} - avatarID {1}", remoteClient.AgentId, avatarID);
  855. return;
  856. }
  857. // Can't handle NPC yet...
  858. ScenePresence p = FindPresence(avatarID);
  859. if (null != p)
  860. {
  861. if (p.PresenceType == PresenceType.Npc)
  862. return;
  863. }
  864. string serverURI = string.Empty;
  865. bool foreign = GetUserProfileServerURI(avatarID, out serverURI);
  866. UserAccount account = null;
  867. Dictionary<string,object> userInfo;
  868. if (!foreign)
  869. {
  870. account = Scene.UserAccountService.GetUserAccount(Scene.RegionInfo.ScopeID, avatarID);
  871. }
  872. else
  873. {
  874. userInfo = new Dictionary<string, object>();
  875. }
  876. Byte[] charterMember = new Byte[1];
  877. string born = String.Empty;
  878. uint flags = 0x00;
  879. if (null != account)
  880. {
  881. if (account.UserTitle == "")
  882. {
  883. charterMember[0] = (Byte)((account.UserFlags & 0xf00) >> 8);
  884. }
  885. else
  886. {
  887. charterMember = Utils.StringToBytes(account.UserTitle);
  888. }
  889. born = Util.ToDateTime(account.Created).ToString(
  890. "M/d/yyyy", CultureInfo.InvariantCulture);
  891. flags = (uint)(account.UserFlags & 0xff);
  892. }
  893. else
  894. {
  895. if (GetUserAccountData(avatarID, out userInfo) == true)
  896. {
  897. if ((string)userInfo["user_title"] == "")
  898. {
  899. charterMember[0] = (Byte)(((Byte)userInfo["user_flags"] & 0xf00) >> 8);
  900. }
  901. else
  902. {
  903. charterMember = Utils.StringToBytes((string)userInfo["user_title"]);
  904. }
  905. int val_born = (int)userInfo["user_created"];
  906. born = Util.ToDateTime(val_born).ToString(
  907. "M/d/yyyy", CultureInfo.InvariantCulture);
  908. // picky, picky
  909. int val_flags = (int)userInfo["user_flags"];
  910. flags = (uint)(val_flags & 0xff);
  911. }
  912. }
  913. UserProfileProperties props = new UserProfileProperties();
  914. string result = string.Empty;
  915. props.UserId = avatarID;
  916. if (!GetProfileData(ref props, foreign, out result))
  917. {
  918. // m_log.DebugFormat("Error getting profile for {0}: {1}", avatarID, result);
  919. return;
  920. }
  921. remoteClient.SendAvatarProperties(props.UserId, props.AboutText, born, charterMember , props.FirstLifeText, flags,
  922. props.FirstLifeImageId, props.ImageId, props.WebUrl, props.PartnerId);
  923. remoteClient.SendAvatarInterestsReply(props.UserId, (uint)props.WantToMask, props.WantToText, (uint)props.SkillsMask,
  924. props.SkillsText, props.Language);
  925. }
  926. /// <summary>
  927. /// Updates the avatar properties.
  928. /// </summary>
  929. /// <param name='remoteClient'>
  930. /// Remote client.
  931. /// </param>
  932. /// <param name='newProfile'>
  933. /// New profile.
  934. /// </param>
  935. public void AvatarPropertiesUpdate(IClientAPI remoteClient, UserProfileData newProfile)
  936. {
  937. if (remoteClient.AgentId == newProfile.ID)
  938. {
  939. UserProfileProperties prop = new UserProfileProperties();
  940. prop.UserId = remoteClient.AgentId;
  941. prop.WebUrl = newProfile.ProfileUrl;
  942. prop.ImageId = newProfile.Image;
  943. prop.AboutText = newProfile.AboutText;
  944. prop.FirstLifeImageId = newProfile.FirstLifeImage;
  945. prop.FirstLifeText = newProfile.FirstLifeAboutText;
  946. string serverURI = string.Empty;
  947. GetUserProfileServerURI(remoteClient.AgentId, out serverURI);
  948. object Prop = prop;
  949. if(!rpc.JsonRpcRequest(ref Prop, "avatar_properties_update", serverURI, UUID.Random().ToString()))
  950. {
  951. remoteClient.SendAgentAlertMessage(
  952. "Error updating properties", false);
  953. return;
  954. }
  955. RequestAvatarProperties(remoteClient, newProfile.ID);
  956. }
  957. }
  958. /// <summary>
  959. /// Gets the profile data.
  960. /// </summary>
  961. /// <returns>
  962. /// The profile data.
  963. /// </returns>
  964. bool GetProfileData(ref UserProfileProperties properties, bool foreign, out string message)
  965. {
  966. // Can't handle NPC yet...
  967. ScenePresence p = FindPresence(properties.UserId);
  968. if (null != p)
  969. {
  970. if (p.PresenceType == PresenceType.Npc)
  971. {
  972. message = "Id points to NPC";
  973. return false;
  974. }
  975. }
  976. string serverURI = string.Empty;
  977. GetUserProfileServerURI(properties.UserId, out serverURI);
  978. // This is checking a friend on the home grid
  979. // Not HG friend
  980. if (String.IsNullOrEmpty(serverURI))
  981. {
  982. message = "No Presence - foreign friend";
  983. return false;
  984. }
  985. object Prop = (object)properties;
  986. if (!rpc.JsonRpcRequest(ref Prop, "avatar_properties_request", serverURI, UUID.Random().ToString()))
  987. {
  988. // If it's a foreign user then try again using OpenProfile, in case that's what the grid is using
  989. bool secondChanceSuccess = false;
  990. if (foreign)
  991. {
  992. try
  993. {
  994. OpenProfileClient client = new OpenProfileClient(serverURI);
  995. if (client.RequestAvatarPropertiesUsingOpenProfile(ref properties))
  996. secondChanceSuccess = true;
  997. }
  998. catch (Exception e)
  999. {
  1000. m_log.Debug(
  1001. string.Format(
  1002. "[PROFILES]: Request using the OpenProfile API for user {0} to {1} failed",
  1003. properties.UserId, serverURI),
  1004. e);
  1005. // Allow the return 'message' to say "JsonRpcRequest" and not "OpenProfile", because
  1006. // the most likely reason that OpenProfile failed is that the remote server
  1007. // doesn't support OpenProfile, and that's not very interesting.
  1008. }
  1009. }
  1010. if (!secondChanceSuccess)
  1011. {
  1012. message = string.Format("JsonRpcRequest for user {0} to {1} failed", properties.UserId, serverURI);
  1013. m_log.DebugFormat("[PROFILES]: {0}", message);
  1014. return false;
  1015. }
  1016. // else, continue below
  1017. }
  1018. properties = (UserProfileProperties)Prop;
  1019. message = "Success";
  1020. return true;
  1021. }
  1022. #endregion Avatar Properties
  1023. #region Utils
  1024. bool GetImageAssets(UUID avatarId)
  1025. {
  1026. string profileServerURI = string.Empty;
  1027. string assetServerURI = string.Empty;
  1028. bool foreign = GetUserProfileServerURI(avatarId, out profileServerURI);
  1029. if(!foreign)
  1030. return true;
  1031. assetServerURI = UserManagementModule.GetUserServerURL(avatarId, "AssetServerURI");
  1032. if(string.IsNullOrEmpty(profileServerURI) || string.IsNullOrEmpty(assetServerURI))
  1033. return false;
  1034. OSDMap parameters= new OSDMap();
  1035. parameters.Add("avatarId", OSD.FromUUID(avatarId));
  1036. OSD Params = (OSD)parameters;
  1037. if(!rpc.JsonRpcRequest(ref Params, "image_assets_request", profileServerURI, UUID.Random().ToString()))
  1038. {
  1039. return false;
  1040. }
  1041. parameters = (OSDMap)Params;
  1042. if (parameters.ContainsKey("result"))
  1043. {
  1044. OSDArray list = (OSDArray)parameters["result"];
  1045. foreach (OSD asset in list)
  1046. {
  1047. OSDString assetId = (OSDString)asset;
  1048. Scene.AssetService.Get(string.Format("{0}/{1}", assetServerURI, assetId.AsString()));
  1049. }
  1050. return true;
  1051. }
  1052. else
  1053. {
  1054. m_log.ErrorFormat("[PROFILES]: Problematic response for image_assets_request from {0}", profileServerURI);
  1055. return false;
  1056. }
  1057. }
  1058. /// <summary>
  1059. /// Gets the user account data.
  1060. /// </summary>
  1061. /// <returns>
  1062. /// The user profile data.
  1063. /// </returns>
  1064. /// <param name='userID'>
  1065. /// If set to <c>true</c> user I.
  1066. /// </param>
  1067. /// <param name='userInfo'>
  1068. /// If set to <c>true</c> user info.
  1069. /// </param>
  1070. bool GetUserAccountData(UUID userID, out Dictionary<string, object> userInfo)
  1071. {
  1072. Dictionary<string,object> info = new Dictionary<string, object>();
  1073. if (UserManagementModule.IsLocalGridUser(userID))
  1074. {
  1075. // Is local
  1076. IUserAccountService uas = Scene.UserAccountService;
  1077. UserAccount account = uas.GetUserAccount(Scene.RegionInfo.ScopeID, userID);
  1078. info["user_flags"] = account.UserFlags;
  1079. info["user_created"] = account.Created;
  1080. if (!String.IsNullOrEmpty(account.UserTitle))
  1081. info["user_title"] = account.UserTitle;
  1082. else
  1083. info["user_title"] = "";
  1084. userInfo = info;
  1085. return false;
  1086. }
  1087. else
  1088. {
  1089. // Is Foreign
  1090. string home_url = UserManagementModule.GetUserServerURL(userID, "HomeURI");
  1091. if (String.IsNullOrEmpty(home_url))
  1092. {
  1093. info["user_flags"] = 0;
  1094. info["user_created"] = 0;
  1095. info["user_title"] = "Unavailable";
  1096. userInfo = info;
  1097. return true;
  1098. }
  1099. UserAgentServiceConnector uConn = new UserAgentServiceConnector(home_url);
  1100. Dictionary<string, object> account;
  1101. try
  1102. {
  1103. account = uConn.GetUserInfo(userID);
  1104. }
  1105. catch (Exception e)
  1106. {
  1107. m_log.Debug("[PROFILES]: GetUserInfo call failed ", e);
  1108. account = new Dictionary<string, object>();
  1109. }
  1110. if (account.Count > 0)
  1111. {
  1112. if (account.ContainsKey("user_flags"))
  1113. info["user_flags"] = account["user_flags"];
  1114. else
  1115. info["user_flags"] = "";
  1116. if (account.ContainsKey("user_created"))
  1117. info["user_created"] = account["user_created"];
  1118. else
  1119. info["user_created"] = "";
  1120. info["user_title"] = "HG Visitor";
  1121. }
  1122. else
  1123. {
  1124. info["user_flags"] = 0;
  1125. info["user_created"] = 0;
  1126. info["user_title"] = "HG Visitor";
  1127. }
  1128. userInfo = info;
  1129. return true;
  1130. }
  1131. }
  1132. /// <summary>
  1133. /// Gets the user gatekeeper server URI.
  1134. /// </summary>
  1135. /// <returns>
  1136. /// The user gatekeeper server URI.
  1137. /// </returns>
  1138. /// <param name='userID'>
  1139. /// If set to <c>true</c> user URI.
  1140. /// </param>
  1141. /// <param name='serverURI'>
  1142. /// If set to <c>true</c> server URI.
  1143. /// </param>
  1144. bool GetUserGatekeeperURI(UUID userID, out string serverURI)
  1145. {
  1146. bool local;
  1147. local = UserManagementModule.IsLocalGridUser(userID);
  1148. if (!local)
  1149. {
  1150. serverURI = UserManagementModule.GetUserServerURL(userID, "GatekeeperURI");
  1151. // Is Foreign
  1152. return true;
  1153. }
  1154. else
  1155. {
  1156. serverURI = MyGatekeeper;
  1157. // Is local
  1158. return false;
  1159. }
  1160. }
  1161. /// <summary>
  1162. /// Gets the user profile server UR.
  1163. /// </summary>
  1164. /// <returns>
  1165. /// The user profile server UR.
  1166. /// </returns>
  1167. /// <param name='userID'>
  1168. /// If set to <c>true</c> user I.
  1169. /// </param>
  1170. /// <param name='serverURI'>
  1171. /// If set to <c>true</c> server UR.
  1172. /// </param>
  1173. bool GetUserProfileServerURI(UUID userID, out string serverURI)
  1174. {
  1175. bool local;
  1176. local = UserManagementModule.IsLocalGridUser(userID);
  1177. if (!local)
  1178. {
  1179. serverURI = UserManagementModule.GetUserServerURL(userID, "ProfileServerURI");
  1180. // Is Foreign
  1181. return true;
  1182. }
  1183. else
  1184. {
  1185. serverURI = ProfileServerUri;
  1186. // Is local
  1187. return false;
  1188. }
  1189. }
  1190. /// <summary>
  1191. /// Finds the presence.
  1192. /// </summary>
  1193. /// <returns>
  1194. /// The presence.
  1195. /// </returns>
  1196. /// <param name='clientID'>
  1197. /// Client I.
  1198. /// </param>
  1199. ScenePresence FindPresence(UUID clientID)
  1200. {
  1201. ScenePresence p;
  1202. p = Scene.GetScenePresence(clientID);
  1203. if (p != null && !p.IsChildAgent)
  1204. return p;
  1205. return null;
  1206. }
  1207. #endregion Util
  1208. }
  1209. }