OGS1UserServices.cs 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775
  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 OpenSim Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections;
  29. using System.Collections.Generic;
  30. using System.Net;
  31. using System.Reflection;
  32. using System.Text.RegularExpressions;
  33. using libsecondlife;
  34. using log4net;
  35. using Nwc.XmlRpc;
  36. using OpenSim.Framework;
  37. using OpenSim.Framework.Communications;
  38. namespace OpenSim.Region.Communications.OGS1
  39. {
  40. public class OGS1UserServices : IUserService, IAvatarService
  41. {
  42. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  43. private CommunicationsOGS1 m_parent;
  44. public OGS1UserServices(CommunicationsOGS1 parent)
  45. {
  46. m_parent = parent;
  47. }
  48. public UserProfileData ConvertXMLRPCDataToUserProfile(Hashtable data)
  49. {
  50. if (data.Contains("error_type"))
  51. {
  52. m_log.Warn("[GRID]: " +
  53. "Error sent by user server when trying to get user profile: (" +
  54. data["error_type"] +
  55. "): " + data["error_desc"]);
  56. return null;
  57. }
  58. UserProfileData userData = new UserProfileData();
  59. userData.FirstName = (string) data["firstname"];
  60. userData.SurName = (string) data["lastname"];
  61. userData.ID = new LLUUID((string) data["uuid"]);
  62. userData.UserInventoryURI = (string) data["server_inventory"];
  63. userData.UserAssetURI = (string) data["server_asset"];
  64. userData.FirstLifeAboutText = (string) data["profile_firstlife_about"];
  65. userData.FirstLifeImage = new LLUUID((string) data["profile_firstlife_image"]);
  66. userData.CanDoMask = Convert.ToUInt32((string) data["profile_can_do"]);
  67. userData.WantDoMask = Convert.ToUInt32(data["profile_want_do"]);
  68. userData.AboutText = (string)data["profile_about"];
  69. userData.Image = new LLUUID((string) data["profile_image"]);
  70. userData.LastLogin = Convert.ToInt32((string) data["profile_lastlogin"]);
  71. userData.HomeRegion = Convert.ToUInt64((string) data["home_region"]);
  72. userData.HomeLocation =
  73. new LLVector3((float) Convert.ToDecimal((string) data["home_coordinates_x"]),
  74. (float) Convert.ToDecimal((string) data["home_coordinates_y"]),
  75. (float) Convert.ToDecimal((string) data["home_coordinates_z"]));
  76. userData.HomeLookAt =
  77. new LLVector3((float) Convert.ToDecimal((string) data["home_look_x"]),
  78. (float) Convert.ToDecimal((string) data["home_look_y"]),
  79. (float) Convert.ToDecimal((string) data["home_look_z"]));
  80. return userData;
  81. }
  82. /// <summary>
  83. /// Get a user agent from the user server
  84. /// </summary>
  85. /// <param name="avatarID"></param>
  86. /// <returns>null if the request fails</returns>
  87. public UserAgentData GetAgentByUUID(LLUUID userId)
  88. {
  89. try
  90. {
  91. Hashtable param = new Hashtable();
  92. param["avatar_uuid"] = userId.ToString();
  93. IList parameters = new ArrayList();
  94. parameters.Add(param);
  95. XmlRpcRequest req = new XmlRpcRequest("get_agent_by_uuid", parameters);
  96. XmlRpcResponse resp = req.Send(m_parent.NetworkServersInfo.UserURL, 6000);
  97. Hashtable respData = (Hashtable) resp.Value;
  98. if (respData.Contains("error_type"))
  99. {
  100. m_log.Warn("[GRID]: " +
  101. "Error sent by user server when trying to get agent: (" +
  102. (string) respData["error_type"] +
  103. "): " + (string)respData["error_desc"]);
  104. return null;
  105. }
  106. LLUUID sessionid = LLUUID.Zero;
  107. UserAgentData userAgent = new UserAgentData();
  108. userAgent.Handle = Convert.ToUInt64((string)respData["handle"]);
  109. Helpers.TryParse((string)respData["sessionid"], out sessionid);
  110. userAgent.SessionID = sessionid;
  111. if ((string)respData["agent_online"] == "TRUE")
  112. {
  113. userAgent.AgentOnline = true;
  114. }
  115. else
  116. {
  117. userAgent.AgentOnline = false;
  118. }
  119. return userAgent;
  120. }
  121. catch (Exception e)
  122. {
  123. m_log.ErrorFormat(
  124. "[OGS1 USER SERVICES]: Error when trying to fetch agent data by uuid from remote user server: {0}",
  125. e);
  126. }
  127. return null;
  128. }
  129. public AvatarAppearance ConvertXMLRPCDataToAvatarAppearance(Hashtable data)
  130. {
  131. if (data != null)
  132. {
  133. if (data.Contains("error_type"))
  134. {
  135. m_log.Warn("[GRID]: " +
  136. "Error sent by user server when trying to get user appearance: (" +
  137. data["error_type"] +
  138. "): " + data["error_desc"]);
  139. return null;
  140. }
  141. else
  142. {
  143. return new AvatarAppearance(data);
  144. }
  145. }
  146. else
  147. {
  148. m_log.Error("[GRID]: The avatar appearance is null, something bad happenend");
  149. return null;
  150. }
  151. }
  152. public List<AvatarPickerAvatar> ConvertXMLRPCDataToAvatarPickerList(LLUUID queryID, Hashtable data)
  153. {
  154. List<AvatarPickerAvatar> pickerlist = new List<AvatarPickerAvatar>();
  155. int pickercount = Convert.ToInt32((string) data["avcount"]);
  156. LLUUID respqueryID = new LLUUID((string) data["queryid"]);
  157. if (queryID == respqueryID)
  158. {
  159. for (int i = 0; i < pickercount; i++)
  160. {
  161. AvatarPickerAvatar apicker = new AvatarPickerAvatar();
  162. LLUUID avatarID = new LLUUID((string) data["avatarid" + i.ToString()]);
  163. string firstname = (string) data["firstname" + i.ToString()];
  164. string lastname = (string) data["lastname" + i.ToString()];
  165. apicker.AvatarID = avatarID;
  166. apicker.firstName = firstname;
  167. apicker.lastName = lastname;
  168. pickerlist.Add(apicker);
  169. }
  170. }
  171. else
  172. {
  173. m_log.Warn("[OGS1 USER SERVICES]: Got invalid queryID from userServer");
  174. }
  175. return pickerlist;
  176. }
  177. public List<FriendListItem> ConvertXMLRPCDataToFriendListItemList(Hashtable data)
  178. {
  179. List<FriendListItem> buddylist = new List<FriendListItem>();
  180. int buddycount = Convert.ToInt32((string)data["avcount"]);
  181. for (int i = 0; i < buddycount; i++)
  182. {
  183. FriendListItem buddylistitem = new FriendListItem();
  184. buddylistitem.FriendListOwner = new LLUUID((string)data["ownerID" + i.ToString()]);
  185. buddylistitem.Friend = new LLUUID((string)data["friendID" + i.ToString()]);
  186. buddylistitem.FriendListOwnerPerms = (uint)Convert.ToInt32((string)data["ownerPerms" + i.ToString()]);
  187. buddylistitem.FriendPerms = (uint)Convert.ToInt32((string)data["friendPerms" + i.ToString()]);
  188. buddylist.Add(buddylistitem);
  189. }
  190. return buddylist;
  191. }
  192. /// <summary>
  193. /// Logs off a user on the user server
  194. /// </summary>
  195. /// <param name="UserID">UUID of the user</param>
  196. /// <param name="regionData">UUID of the Region</param>
  197. /// <param name="posx">final position x</param>
  198. /// <param name="posy">final position y</param>
  199. /// <param name="posz">final position z</param>
  200. public void LogOffUser(LLUUID userid, LLUUID regionid, ulong regionhandle, float posx, float posy, float posz)
  201. {
  202. Hashtable param = new Hashtable();
  203. param["avatar_uuid"] = userid.UUID.ToString();
  204. param["region_uuid"] = regionid.UUID.ToString();
  205. param["region_handle"] = regionhandle.ToString();
  206. param["region_pos_x"] = posx.ToString();
  207. param["region_pos_y"] = posy.ToString();
  208. param["region_pos_z"] = posz.ToString();
  209. IList parameters = new ArrayList();
  210. parameters.Add(param);
  211. XmlRpcRequest req = new XmlRpcRequest("logout_of_simulator", parameters);
  212. try
  213. {
  214. req.Send(m_parent.NetworkServersInfo.UserURL, 3000);
  215. }
  216. catch (WebException)
  217. {
  218. m_log.Warn("[LOGOFF]: Unable to notify grid server of user logoff");
  219. }
  220. }
  221. public UserProfileData GetUserProfile(string firstName, string lastName)
  222. {
  223. return GetUserProfile(firstName + " " + lastName);
  224. }
  225. public void UpdateUserCurrentRegion(LLUUID avatarid, LLUUID regionuuid, ulong regionhandle)
  226. {
  227. Hashtable param = new Hashtable();
  228. param.Add("avatar_id", avatarid.ToString());
  229. param.Add("region_uuid", regionuuid.ToString());
  230. param.Add("region_handle", regionhandle.ToString());
  231. IList parameters = new ArrayList();
  232. parameters.Add(param);
  233. XmlRpcRequest req = new XmlRpcRequest("update_user_current_region", parameters);
  234. XmlRpcResponse resp;
  235. try
  236. {
  237. resp = req.Send(m_parent.NetworkServersInfo.UserURL, 3000);
  238. }
  239. catch(WebException)
  240. {
  241. m_log.Warn("[OSG1 USER SERVICES]: Grid not responding. Retrying.");
  242. try
  243. {
  244. resp = req.Send(m_parent.NetworkServersInfo.UserURL, 3000);
  245. }
  246. catch (WebException)
  247. {
  248. m_log.Warn("[OSG1 USER SERVICES]: Grid not responding. Failed.");
  249. return;
  250. }
  251. }
  252. if (resp == null)
  253. {
  254. m_log.Warn("[OSG1 USER SERVICES]: Got no response, Grid server may not be updated.");
  255. return;
  256. }
  257. Hashtable respData = (Hashtable)resp.Value;
  258. if (respData == null || !respData.ContainsKey("returnString"))
  259. {
  260. m_log.Warn("[OSG1 USER SERVICES]: Error updating user record, Grid server may not be updated.");
  261. }
  262. else
  263. {
  264. if ((string) respData["returnString"] == "TRUE")
  265. {
  266. m_log.Info("[OSG1 USER SERVICES]: Successfully updated user record");
  267. }
  268. else
  269. {
  270. m_log.Error("[OSG1 USER SERVICES]: Error updating user record");
  271. }
  272. }
  273. }
  274. public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(LLUUID queryID, string query)
  275. {
  276. List<AvatarPickerAvatar> pickerlist = new List<AvatarPickerAvatar>();
  277. Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9 ]");
  278. try
  279. {
  280. Hashtable param = new Hashtable();
  281. param["queryid"] = (string) queryID.ToString();
  282. param["avquery"] = objAlphaNumericPattern.Replace(query, String.Empty);
  283. IList parameters = new ArrayList();
  284. parameters.Add(param);
  285. XmlRpcRequest req = new XmlRpcRequest("get_avatar_picker_avatar", parameters);
  286. XmlRpcResponse resp = req.Send(m_parent.NetworkServersInfo.UserURL, 3000);
  287. Hashtable respData = (Hashtable) resp.Value;
  288. pickerlist = ConvertXMLRPCDataToAvatarPickerList(queryID, respData);
  289. }
  290. catch (WebException e)
  291. {
  292. m_log.Warn("[OGS1 USER SERVICES]: Error when trying to fetch Avatar Picker Response: " +
  293. e.Message);
  294. // Return Empty picker list (no results)
  295. }
  296. return pickerlist;
  297. }
  298. /// <summary>
  299. /// Get a user profile from the user server
  300. /// </summary>
  301. /// <param name="avatarID"></param>
  302. /// <returns>null if the request fails</returns>
  303. public UserProfileData GetUserProfile(string name)
  304. {
  305. try
  306. {
  307. Hashtable param = new Hashtable();
  308. param["avatar_name"] = name;
  309. IList parameters = new ArrayList();
  310. parameters.Add(param);
  311. XmlRpcRequest req = new XmlRpcRequest("get_user_by_name", parameters);
  312. XmlRpcResponse resp = req.Send(m_parent.NetworkServersInfo.UserURL, 6000);
  313. Hashtable respData = (Hashtable) resp.Value;
  314. return ConvertXMLRPCDataToUserProfile(respData);
  315. }
  316. catch (WebException e)
  317. {
  318. m_log.ErrorFormat(
  319. "[OGS1 USER SERVICES]: Error when trying to fetch profile data by name from remote user server: {0}",
  320. e);
  321. }
  322. return null;
  323. }
  324. /// <summary>
  325. /// Get a user profile from the user server
  326. /// </summary>
  327. /// <param name="avatarID"></param>
  328. /// <returns>null if the request fails</returns>
  329. public UserProfileData GetUserProfile(LLUUID avatarID)
  330. {
  331. try
  332. {
  333. Hashtable param = new Hashtable();
  334. param["avatar_uuid"] = avatarID.ToString();
  335. IList parameters = new ArrayList();
  336. parameters.Add(param);
  337. XmlRpcRequest req = new XmlRpcRequest("get_user_by_uuid", parameters);
  338. XmlRpcResponse resp = req.Send(m_parent.NetworkServersInfo.UserURL, 6000);
  339. Hashtable respData = (Hashtable) resp.Value;
  340. return ConvertXMLRPCDataToUserProfile(respData);
  341. }
  342. catch (Exception e)
  343. {
  344. m_log.ErrorFormat(
  345. "[OGS1 USER SERVICES]: Error when trying to fetch profile data by uuid from remote user server: {0}",
  346. e);
  347. }
  348. return null;
  349. }
  350. public void ClearUserAgent(LLUUID avatarID)
  351. {
  352. // TODO: implement
  353. }
  354. /// <summary>
  355. /// Retrieve the user information for the given master uuid.
  356. /// </summary>
  357. /// <param name="uuid"></param>
  358. /// <returns></returns>
  359. public UserProfileData SetupMasterUser(string firstName, string lastName)
  360. {
  361. return SetupMasterUser(firstName, lastName, String.Empty);
  362. }
  363. /// <summary>
  364. /// Retrieve the user information for the given master uuid.
  365. /// </summary>
  366. /// <param name="uuid"></param>
  367. /// <returns></returns>
  368. public UserProfileData SetupMasterUser(string firstName, string lastName, string password)
  369. {
  370. UserProfileData profile = GetUserProfile(firstName, lastName);
  371. return profile;
  372. }
  373. /// <summary>
  374. /// Retrieve the user information for the given master uuid.
  375. /// </summary>
  376. /// <param name="uuid"></param>
  377. /// <returns></returns>
  378. public UserProfileData SetupMasterUser(LLUUID uuid)
  379. {
  380. UserProfileData data = GetUserProfile(uuid);
  381. if (data == null)
  382. {
  383. throw new Exception(
  384. "Could not retrieve profile for master user " + uuid + ". User server did not respond to the request.");
  385. }
  386. return data;
  387. }
  388. public LLUUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY)
  389. {
  390. throw new Exception("The method or operation is not implemented.");
  391. }
  392. // TODO
  393. public bool UpdateUserProfile(UserProfileData data)
  394. {
  395. return false;
  396. }
  397. public bool UpdateUserProfileProperties(UserProfileData UserProfile)
  398. {
  399. m_log.Debug("[OGS1 USER SERVICES]: Asking UserServer to update profile.");
  400. Hashtable param = new Hashtable();
  401. param["avatar_uuid"] = UserProfile.ID.ToString();
  402. //param["AllowPublish"] = UserProfile.ToString();
  403. param["FLImageID"] = UserProfile.FirstLifeImage.ToString();
  404. param["ImageID"] = UserProfile.Image.ToString();
  405. //param["MaturePublish"] = MaturePublish.ToString();
  406. param["AboutText"] = UserProfile.AboutText;
  407. param["FLAboutText"] = UserProfile.FirstLifeAboutText;
  408. //param["ProfileURL"] = UserProfile.ProfileURL.ToString();
  409. param["home_region"] = UserProfile.HomeRegion.ToString();
  410. param["home_pos_x"] = UserProfile.HomeLocationX.ToString();
  411. param["home_pos_y"] = UserProfile.HomeLocationY.ToString();
  412. param["home_pos_z"] = UserProfile.HomeLocationZ.ToString();
  413. param["home_look_x"] = UserProfile.HomeLookAtX.ToString();
  414. param["home_look_y"] = UserProfile.HomeLookAtY.ToString();
  415. param["home_look_z"] = UserProfile.HomeLookAtZ.ToString();
  416. IList parameters = new ArrayList();
  417. parameters.Add(param);
  418. XmlRpcRequest req = new XmlRpcRequest("update_user_profile", parameters);
  419. XmlRpcResponse resp = req.Send(m_parent.NetworkServersInfo.UserURL, 3000);
  420. Hashtable respData = (Hashtable)resp.Value;
  421. if (respData != null)
  422. {
  423. if (respData.Contains("returnString"))
  424. {
  425. if (((string)respData["returnString"]).ToUpper() != "TRUE")
  426. {
  427. m_log.Warn("[GRID]: Unable to update user profile, User Server Reported an issue");
  428. return false;
  429. }
  430. }
  431. else
  432. {
  433. m_log.Warn("[GRID]: Unable to update user profile, UserServer didn't understand me!");
  434. return false;
  435. }
  436. }
  437. else
  438. {
  439. m_log.Warn("[GRID]: Unable to update user profile, UserServer didn't understand me!");
  440. return false;
  441. }
  442. return true;
  443. }
  444. #region IUserServices Friend Methods
  445. /// <summary>
  446. /// Adds a new friend to the database for XUser
  447. /// </summary>
  448. /// <param name="friendlistowner">The agent that who's friends list is being added to</param>
  449. /// <param name="friend">The agent that being added to the friends list of the friends list owner</param>
  450. /// <param name="perms">A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects </param>
  451. public void AddNewUserFriend(LLUUID friendlistowner, LLUUID friend, uint perms)
  452. {
  453. try
  454. {
  455. Hashtable param = new Hashtable();
  456. param["ownerID"] = friendlistowner.UUID.ToString();
  457. param["friendID"] = friend.UUID.ToString();
  458. param["friendPerms"] = perms.ToString();
  459. IList parameters = new ArrayList();
  460. parameters.Add(param);
  461. XmlRpcRequest req = new XmlRpcRequest("add_new_user_friend", parameters);
  462. XmlRpcResponse resp = req.Send(m_parent.NetworkServersInfo.UserURL, 3000);
  463. Hashtable respData = (Hashtable)resp.Value;
  464. if (respData != null)
  465. {
  466. if (respData.Contains("returnString"))
  467. {
  468. if ((string)respData["returnString"] == "TRUE")
  469. {
  470. }
  471. else
  472. {
  473. m_log.Warn("[GRID]: Unable to add new friend, User Server Reported an issue");
  474. }
  475. }
  476. else
  477. {
  478. m_log.Warn("[GRID]: Unable to add new friend, UserServer didn't understand me!");
  479. }
  480. }
  481. else
  482. {
  483. m_log.Warn("[GRID]: Unable to add new friend, UserServer didn't understand me!");
  484. }
  485. }
  486. catch (WebException e)
  487. {
  488. m_log.Warn("[GRID]: Error when trying to AddNewUserFriend: " +
  489. e.Message);
  490. }
  491. }
  492. /// <summary>
  493. /// Delete friend on friendlistowner's friendlist.
  494. /// </summary>
  495. /// <param name="friendlistowner">The agent that who's friends list is being updated</param>
  496. /// <param name="friend">The Ex-friend agent</param>
  497. public void RemoveUserFriend(LLUUID friendlistowner, LLUUID friend)
  498. {
  499. try
  500. {
  501. Hashtable param = new Hashtable();
  502. param["ownerID"] = friendlistowner.UUID.ToString();
  503. param["friendID"] = friend.UUID.ToString();
  504. IList parameters = new ArrayList();
  505. parameters.Add(param);
  506. XmlRpcRequest req = new XmlRpcRequest("remove_user_friend", parameters);
  507. XmlRpcResponse resp = req.Send(m_parent.NetworkServersInfo.UserURL, 3000);
  508. Hashtable respData = (Hashtable)resp.Value;
  509. if (respData != null)
  510. {
  511. if (respData.Contains("returnString"))
  512. {
  513. if ((string)respData["returnString"] == "TRUE")
  514. {
  515. }
  516. else
  517. {
  518. m_log.Warn("[GRID]: Unable to remove friend, User Server Reported an issue");
  519. }
  520. }
  521. else
  522. {
  523. m_log.Warn("[GRID]: Unable to remove friend, UserServer didn't understand me!");
  524. }
  525. }
  526. else
  527. {
  528. m_log.Warn("[GRID]: Unable to remove friend, UserServer didn't understand me!");
  529. }
  530. }
  531. catch (WebException e)
  532. {
  533. m_log.Warn("[GRID]: Error when trying to RemoveUserFriend: " +
  534. e.Message);
  535. }
  536. }
  537. /// <summary>
  538. /// Update permissions for friend on friendlistowner's friendlist.
  539. /// </summary>
  540. /// <param name="friendlistowner">The agent that who's friends list is being updated</param>
  541. /// <param name="friend">The agent that is getting or loosing permissions</param>
  542. /// <param name="perms">A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects </param>
  543. public void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms)
  544. {
  545. try
  546. {
  547. Hashtable param = new Hashtable();
  548. param["ownerID"] = friendlistowner.UUID.ToString();
  549. param["friendID"] = friend.UUID.ToString();
  550. param["friendPerms"] = perms.ToString();
  551. IList parameters = new ArrayList();
  552. parameters.Add(param);
  553. XmlRpcRequest req = new XmlRpcRequest("update_user_friend_perms", parameters);
  554. XmlRpcResponse resp = req.Send(m_parent.NetworkServersInfo.UserURL, 3000);
  555. Hashtable respData = (Hashtable)resp.Value;
  556. if (respData != null)
  557. {
  558. if (respData.Contains("returnString"))
  559. {
  560. if ((string)respData["returnString"] == "TRUE")
  561. {
  562. }
  563. else
  564. {
  565. m_log.Warn("[GRID]: Unable to update_user_friend_perms, User Server Reported an issue");
  566. }
  567. }
  568. else
  569. {
  570. m_log.Warn("[GRID]: Unable to update_user_friend_perms, UserServer didn't understand me!");
  571. }
  572. }
  573. else
  574. {
  575. m_log.Warn("[GRID]: Unable to update_user_friend_perms, UserServer didn't understand me!");
  576. }
  577. }
  578. catch (WebException e)
  579. {
  580. m_log.Warn("[GRID]: Error when trying to update_user_friend_perms: " +
  581. e.Message);
  582. }
  583. }
  584. /// <summary>
  585. /// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship for LLUUID friendslistowner
  586. /// </summary>
  587. /// <param name="friendlistowner">The agent that we're retreiving the friends Data.</param>
  588. public List<FriendListItem> GetUserFriendList(LLUUID friendlistowner)
  589. {
  590. List<FriendListItem> buddylist = new List<FriendListItem>();
  591. try
  592. {
  593. Hashtable param = new Hashtable();
  594. param["ownerID"] = friendlistowner.UUID.ToString();
  595. IList parameters = new ArrayList();
  596. parameters.Add(param);
  597. XmlRpcRequest req = new XmlRpcRequest("get_user_friend_list", parameters);
  598. XmlRpcResponse resp = req.Send(m_parent.NetworkServersInfo.UserURL, 8000);
  599. Hashtable respData = (Hashtable) resp.Value;
  600. if (respData.Contains("avcount"))
  601. {
  602. buddylist = ConvertXMLRPCDataToFriendListItemList(respData);
  603. }
  604. }
  605. catch (WebException e)
  606. {
  607. m_log.Warn("[OGS1 USER SERVICES]: Error when trying to fetch Avatar's friends list: " +
  608. e.Message);
  609. // Return Empty list (no friends)
  610. }
  611. return buddylist;
  612. }
  613. #endregion
  614. /// Appearance
  615. public AvatarAppearance GetUserAppearance(LLUUID user)
  616. {
  617. AvatarAppearance appearance = null;
  618. try
  619. {
  620. Hashtable param = new Hashtable();
  621. param["owner"] = user.ToString();
  622. IList parameters = new ArrayList();
  623. parameters.Add(param);
  624. XmlRpcRequest req = new XmlRpcRequest("get_avatar_appearance", parameters);
  625. XmlRpcResponse resp = req.Send(m_parent.NetworkServersInfo.UserURL, 8000);
  626. Hashtable respData = (Hashtable) resp.Value;
  627. return ConvertXMLRPCDataToAvatarAppearance(respData);
  628. }
  629. catch (WebException e)
  630. {
  631. m_log.ErrorFormat("[OGS1 USER SERVICES]: Network problems when trying to fetch appearance for avatar {0}, {1}", user, e.Message);
  632. }
  633. return appearance;
  634. }
  635. public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance)
  636. {
  637. try
  638. {
  639. Hashtable param = appearance.ToHashTable();
  640. param["owner"] = user.ToString();
  641. IList parameters = new ArrayList();
  642. parameters.Add(param);
  643. XmlRpcRequest req = new XmlRpcRequest("update_avatar_appearance", parameters);
  644. XmlRpcResponse resp = req.Send(m_parent.NetworkServersInfo.UserURL, 8000);
  645. Hashtable respData = (Hashtable) resp.Value;
  646. if (respData != null)
  647. {
  648. if (respData.Contains("returnString"))
  649. {
  650. if ((string)respData["returnString"] == "TRUE")
  651. {
  652. }
  653. else
  654. {
  655. m_log.Warn("[GRID]: Unable to update_user_appearance, User Server Reported an issue");
  656. }
  657. }
  658. else
  659. {
  660. m_log.Warn("[GRID]: Unable to update_user_appearance, UserServer didn't understand me!");
  661. }
  662. }
  663. else
  664. {
  665. m_log.Warn("[GRID]: Unable to update_user_appearance, UserServer didn't understand me!");
  666. }
  667. }
  668. catch (WebException e)
  669. {
  670. m_log.Warn("[OGS1 USER SERVICES]: Error when trying to update Avatar's appearance: " +
  671. e.Message);
  672. // Return Empty list (no friends)
  673. }
  674. }
  675. public void AddAttachment(LLUUID user, LLUUID item)
  676. {
  677. return;
  678. }
  679. public void RemoveAttachment(LLUUID user, LLUUID item)
  680. {
  681. return;
  682. }
  683. public List<LLUUID> GetAttachments(LLUUID user)
  684. {
  685. return new List<LLUUID>();
  686. }
  687. }
  688. }