diff options
author | BlueWall | 2013-05-30 22:16:42 -0400 |
---|---|---|
committer | BlueWall | 2013-05-30 22:16:42 -0400 |
commit | e85c70223afc16da5168ce7c481d70dd47b8e149 (patch) | |
tree | cba3def9e12eec4ec69b0573b5f09ce99261c873 /OpenSim/Services/UserProfilesService | |
parent | If an exception occurs in the AsyncCommandManager loop, spit it out to log ra... (diff) | |
parent | UserProfiles (diff) | |
download | opensim-SC-e85c70223afc16da5168ce7c481d70dd47b8e149.zip opensim-SC-e85c70223afc16da5168ce7c481d70dd47b8e149.tar.gz opensim-SC-e85c70223afc16da5168ce7c481d70dd47b8e149.tar.bz2 opensim-SC-e85c70223afc16da5168ce7c481d70dd47b8e149.tar.xz |
Merge branch 'work' contains UserProfiles with Robust service and updates region module using JsonRpc messaging. Requres no databse changes (but backup existing data before use).
Diffstat (limited to 'OpenSim/Services/UserProfilesService')
-rw-r--r-- | OpenSim/Services/UserProfilesService/UserProfilesService.cs | 160 | ||||
-rw-r--r-- | OpenSim/Services/UserProfilesService/UserProfilesServiceBase.cs | 59 |
2 files changed, 219 insertions, 0 deletions
diff --git a/OpenSim/Services/UserProfilesService/UserProfilesService.cs b/OpenSim/Services/UserProfilesService/UserProfilesService.cs new file mode 100644 index 0000000..959c661 --- /dev/null +++ b/OpenSim/Services/UserProfilesService/UserProfilesService.cs | |||
@@ -0,0 +1,160 @@ | |||
1 | using System; | ||
2 | using System.Reflection; | ||
3 | using System.Text; | ||
4 | using Nini.Config; | ||
5 | using log4net; | ||
6 | using OpenSim.Server.Base; | ||
7 | using OpenSim.Services.Interfaces; | ||
8 | using OpenSim.Services.UserAccountService; | ||
9 | using OpenSim.Data; | ||
10 | using OpenMetaverse; | ||
11 | using OpenMetaverse.StructuredData; | ||
12 | using OpenSim.Framework; | ||
13 | |||
14 | namespace OpenSim.Services.ProfilesService | ||
15 | { | ||
16 | public class UserProfilesService: UserProfilesServiceBase, IUserProfilesService | ||
17 | { | ||
18 | static readonly ILog m_log = | ||
19 | LogManager.GetLogger( | ||
20 | MethodBase.GetCurrentMethod().DeclaringType); | ||
21 | |||
22 | IUserAccountService userAccounts; | ||
23 | IAuthenticationService authService; | ||
24 | |||
25 | public UserProfilesService(IConfigSource config, string configName): | ||
26 | base(config, configName) | ||
27 | { | ||
28 | IConfig Config = config.Configs[configName]; | ||
29 | if (Config == null) | ||
30 | { | ||
31 | m_log.Warn("[PROFILES]: No configuration found!"); | ||
32 | return; | ||
33 | } | ||
34 | Object[] args = null; | ||
35 | |||
36 | args = new Object[] { config }; | ||
37 | string accountService = Config.GetString("UserAccountService", String.Empty); | ||
38 | if (accountService != string.Empty) | ||
39 | userAccounts = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args); | ||
40 | |||
41 | args = new Object[] { config }; | ||
42 | string authServiceConfig = Config.GetString("AuthenticationServiceModule", String.Empty); | ||
43 | if (accountService != string.Empty) | ||
44 | authService = ServerUtils.LoadPlugin<IAuthenticationService>(authServiceConfig, args); | ||
45 | } | ||
46 | |||
47 | #region Classifieds | ||
48 | public OSD AvatarClassifiedsRequest(UUID creatorId) | ||
49 | { | ||
50 | OSDArray records = ProfilesData.GetClassifiedRecords(creatorId); | ||
51 | |||
52 | return records; | ||
53 | } | ||
54 | |||
55 | public bool ClassifiedUpdate(UserClassifiedAdd ad, ref string result) | ||
56 | { | ||
57 | if(!ProfilesData.UpdateClassifiedRecord(ad, ref result)) | ||
58 | { | ||
59 | return false; | ||
60 | } | ||
61 | result = "success"; | ||
62 | return true; | ||
63 | } | ||
64 | |||
65 | public bool ClassifiedDelete(UUID recordId) | ||
66 | { | ||
67 | if(ProfilesData.DeleteClassifiedRecord(recordId)) | ||
68 | return true; | ||
69 | |||
70 | return false; | ||
71 | } | ||
72 | |||
73 | public bool ClassifiedInfoRequest(ref UserClassifiedAdd ad, ref string result) | ||
74 | { | ||
75 | if(ProfilesData.GetClassifiedInfo(ref ad, ref result)) | ||
76 | return true; | ||
77 | |||
78 | return false; | ||
79 | } | ||
80 | #endregion Classifieds | ||
81 | |||
82 | #region Picks | ||
83 | public OSD AvatarPicksRequest(UUID creatorId) | ||
84 | { | ||
85 | OSDArray records = ProfilesData.GetAvatarPicks(creatorId); | ||
86 | |||
87 | return records; | ||
88 | } | ||
89 | |||
90 | public bool PickInfoRequest(ref UserProfilePick pick, ref string result) | ||
91 | { | ||
92 | pick = ProfilesData.GetPickInfo(pick.CreatorId, pick.PickId); | ||
93 | result = "OK"; | ||
94 | return true; | ||
95 | } | ||
96 | |||
97 | public bool PicksUpdate(ref UserProfilePick pick, ref string result) | ||
98 | { | ||
99 | return ProfilesData.UpdatePicksRecord(pick); | ||
100 | } | ||
101 | |||
102 | public bool PicksDelete(UUID pickId) | ||
103 | { | ||
104 | return ProfilesData.DeletePicksRecord(pickId); | ||
105 | } | ||
106 | #endregion Picks | ||
107 | |||
108 | #region Notes | ||
109 | public bool AvatarNotesRequest(ref UserProfileNotes note) | ||
110 | { | ||
111 | return ProfilesData.GetAvatarNotes(ref note); | ||
112 | } | ||
113 | |||
114 | public bool NotesUpdate(ref UserProfileNotes note, ref string result) | ||
115 | { | ||
116 | return ProfilesData.UpdateAvatarNotes(ref note, ref result); | ||
117 | } | ||
118 | #endregion Notes | ||
119 | |||
120 | #region Profile Properties | ||
121 | public bool AvatarPropertiesRequest(ref UserProfileProperties prop, ref string result) | ||
122 | { | ||
123 | return ProfilesData.GetAvatarProperties(ref prop, ref result); | ||
124 | } | ||
125 | |||
126 | public bool AvatarPropertiesUpdate(ref UserProfileProperties prop, ref string result) | ||
127 | { | ||
128 | return ProfilesData.UpdateAvatarProperties(ref prop, ref result); | ||
129 | } | ||
130 | #endregion Profile Properties | ||
131 | |||
132 | #region Interests | ||
133 | public bool AvatarInterestsUpdate(UserProfileProperties prop, ref string result) | ||
134 | { | ||
135 | return ProfilesData.UpdateAvatarInterests(prop, ref result); | ||
136 | } | ||
137 | #endregion Interests | ||
138 | |||
139 | #region Utility | ||
140 | public OSD AvatarImageAssetsRequest(UUID avatarId) | ||
141 | { | ||
142 | OSDArray records = ProfilesData.GetUserImageAssets(avatarId); | ||
143 | return records; | ||
144 | } | ||
145 | #endregion Utility | ||
146 | |||
147 | #region UserData | ||
148 | public bool RequestUserAppData(ref UserAppData prop, ref string result) | ||
149 | { | ||
150 | return ProfilesData.GetUserAppData(ref prop, ref result); | ||
151 | } | ||
152 | |||
153 | public bool SetUserAppData(UserAppData prop, ref string result) | ||
154 | { | ||
155 | return true; | ||
156 | } | ||
157 | #endregion UserData | ||
158 | } | ||
159 | } | ||
160 | |||
diff --git a/OpenSim/Services/UserProfilesService/UserProfilesServiceBase.cs b/OpenSim/Services/UserProfilesService/UserProfilesServiceBase.cs new file mode 100644 index 0000000..dc0be03 --- /dev/null +++ b/OpenSim/Services/UserProfilesService/UserProfilesServiceBase.cs | |||
@@ -0,0 +1,59 @@ | |||
1 | using System; | ||
2 | using System.Reflection; | ||
3 | using Nini.Config; | ||
4 | using log4net; | ||
5 | using OpenSim.Services.Base; | ||
6 | using OpenSim.Data; | ||
7 | |||
8 | namespace OpenSim.Services.ProfilesService | ||
9 | { | ||
10 | public class UserProfilesServiceBase: ServiceBase | ||
11 | { | ||
12 | static readonly ILog m_log = | ||
13 | LogManager.GetLogger( | ||
14 | MethodBase.GetCurrentMethod().DeclaringType); | ||
15 | |||
16 | public IProfilesData ProfilesData; | ||
17 | |||
18 | public string ConfigName | ||
19 | { | ||
20 | get; private set; | ||
21 | } | ||
22 | |||
23 | public UserProfilesServiceBase(IConfigSource config, string configName): | ||
24 | base(config) | ||
25 | { | ||
26 | if(string.IsNullOrEmpty(configName)) | ||
27 | { | ||
28 | m_log.WarnFormat("[PROFILES]: Configuration section not given!"); | ||
29 | return; | ||
30 | } | ||
31 | |||
32 | string dllName = String.Empty; | ||
33 | string connString = null; | ||
34 | string realm = String.Empty; | ||
35 | |||
36 | IConfig dbConfig = config.Configs["DatabaseService"]; | ||
37 | if (dbConfig != null) | ||
38 | { | ||
39 | if (dllName == String.Empty) | ||
40 | dllName = dbConfig.GetString("StorageProvider", String.Empty); | ||
41 | if (string.IsNullOrEmpty(connString)) | ||
42 | connString = dbConfig.GetString("ConnectionString", String.Empty); | ||
43 | } | ||
44 | |||
45 | IConfig ProfilesConfig = config.Configs[configName]; | ||
46 | if (ProfilesConfig != null) | ||
47 | { | ||
48 | connString = ProfilesConfig.GetString("ConnectionString", connString); | ||
49 | realm = ProfilesConfig.GetString("Realm", realm); | ||
50 | } | ||
51 | |||
52 | ProfilesData = LoadPlugin<IProfilesData>(dllName, new Object[] { connString }); | ||
53 | if (ProfilesData == null) | ||
54 | throw new Exception("Could not find a storage interface in the given module"); | ||
55 | |||
56 | } | ||
57 | } | ||
58 | } | ||
59 | |||