UserProfilesService.cs 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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.Reflection;
  29. using System.Text;
  30. using Nini.Config;
  31. using log4net;
  32. using OpenSim.Server.Base;
  33. using OpenSim.Services.Interfaces;
  34. using OpenSim.Services.UserAccountService;
  35. using OpenSim.Data;
  36. using OpenMetaverse;
  37. using OpenMetaverse.StructuredData;
  38. using OpenSim.Framework;
  39. namespace OpenSim.Services.ProfilesService
  40. {
  41. public class UserProfilesService: UserProfilesServiceBase, IUserProfilesService
  42. {
  43. static readonly ILog m_log =
  44. LogManager.GetLogger(
  45. MethodBase.GetCurrentMethod().DeclaringType);
  46. IUserAccountService userAccounts;
  47. IAuthenticationService authService;
  48. public UserProfilesService(IConfigSource config, string configName):
  49. base(config, configName)
  50. {
  51. IConfig Config = config.Configs[configName];
  52. if (Config == null)
  53. {
  54. m_log.Warn("[PROFILES]: No configuration found!");
  55. return;
  56. }
  57. Object[] args = null;
  58. args = new Object[] { config };
  59. string accountService = Config.GetString("UserAccountService", String.Empty);
  60. if (accountService != string.Empty)
  61. userAccounts = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args);
  62. args = new Object[] { config };
  63. string authServiceConfig = Config.GetString("AuthenticationServiceModule", String.Empty);
  64. if (accountService != string.Empty)
  65. authService = ServerUtils.LoadPlugin<IAuthenticationService>(authServiceConfig, args);
  66. }
  67. #region Classifieds
  68. public OSD AvatarClassifiedsRequest(UUID creatorId)
  69. {
  70. OSDArray records = ProfilesData.GetClassifiedRecords(creatorId);
  71. return records;
  72. }
  73. public bool ClassifiedUpdate(UserClassifiedAdd ad, ref string result)
  74. {
  75. if(!ProfilesData.UpdateClassifiedRecord(ad, ref result))
  76. {
  77. return false;
  78. }
  79. result = "success";
  80. return true;
  81. }
  82. public bool ClassifiedDelete(UUID recordId)
  83. {
  84. if(ProfilesData.DeleteClassifiedRecord(recordId))
  85. return true;
  86. return false;
  87. }
  88. public bool ClassifiedInfoRequest(ref UserClassifiedAdd ad, ref string result)
  89. {
  90. if(ProfilesData.GetClassifiedInfo(ref ad, ref result))
  91. return true;
  92. return false;
  93. }
  94. #endregion Classifieds
  95. #region Picks
  96. public OSD AvatarPicksRequest(UUID creatorId)
  97. {
  98. OSDArray records = ProfilesData.GetAvatarPicks(creatorId);
  99. return records;
  100. }
  101. public bool PickInfoRequest(ref UserProfilePick pick, ref string result)
  102. {
  103. pick = ProfilesData.GetPickInfo(pick.CreatorId, pick.PickId);
  104. result = "OK";
  105. return true;
  106. }
  107. public bool PicksUpdate(ref UserProfilePick pick, ref string result)
  108. {
  109. return ProfilesData.UpdatePicksRecord(pick);
  110. }
  111. public bool PicksDelete(UUID pickId)
  112. {
  113. return ProfilesData.DeletePicksRecord(pickId);
  114. }
  115. #endregion Picks
  116. #region Notes
  117. public bool AvatarNotesRequest(ref UserProfileNotes note)
  118. {
  119. return ProfilesData.GetAvatarNotes(ref note);
  120. }
  121. public bool NotesUpdate(ref UserProfileNotes note, ref string result)
  122. {
  123. return ProfilesData.UpdateAvatarNotes(ref note, ref result);
  124. }
  125. #endregion Notes
  126. #region Profile Properties
  127. public bool AvatarPropertiesRequest(ref UserProfileProperties prop, ref string result)
  128. {
  129. return ProfilesData.GetAvatarProperties(ref prop, ref result);
  130. }
  131. public bool AvatarPropertiesUpdate(ref UserProfileProperties prop, ref string result)
  132. {
  133. return ProfilesData.UpdateAvatarProperties(ref prop, ref result);
  134. }
  135. #endregion Profile Properties
  136. #region Interests
  137. public bool AvatarInterestsUpdate(UserProfileProperties prop, ref string result)
  138. {
  139. return ProfilesData.UpdateAvatarInterests(prop, ref result);
  140. }
  141. #endregion Interests
  142. #region Utility
  143. public OSD AvatarImageAssetsRequest(UUID avatarId)
  144. {
  145. OSDArray records = ProfilesData.GetUserImageAssets(avatarId);
  146. return records;
  147. }
  148. #endregion Utility
  149. #region UserData
  150. public bool RequestUserAppData(ref UserAppData prop, ref string result)
  151. {
  152. return ProfilesData.GetUserAppData(ref prop, ref result);
  153. }
  154. public bool SetUserAppData(UserAppData prop, ref string result)
  155. {
  156. return true;
  157. }
  158. #endregion UserData
  159. }
  160. }