diff options
Diffstat (limited to 'OpenSim/Server/Handlers/Profiles')
-rw-r--r-- | OpenSim/Server/Handlers/Profiles/UserProfilesConnector.cs | 112 | ||||
-rw-r--r-- | OpenSim/Server/Handlers/Profiles/UserProfilesHandlers.cs | 461 |
2 files changed, 573 insertions, 0 deletions
diff --git a/OpenSim/Server/Handlers/Profiles/UserProfilesConnector.cs b/OpenSim/Server/Handlers/Profiles/UserProfilesConnector.cs new file mode 100644 index 0000000..28dbbc2 --- /dev/null +++ b/OpenSim/Server/Handlers/Profiles/UserProfilesConnector.cs | |||
@@ -0,0 +1,112 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Reflection; | ||
30 | using Nini.Config; | ||
31 | using OpenSim.Server.Base; | ||
32 | using OpenSim.Services.Interfaces; | ||
33 | using OpenSim.Framework.Servers.HttpServer; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Server.Handlers.Base; | ||
36 | using log4net; | ||
37 | |||
38 | namespace OpenSim.Server.Handlers.Profiles | ||
39 | { | ||
40 | public class UserProfilesConnector: ServiceConnector | ||
41 | { | ||
42 | // static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
43 | |||
44 | // Our Local Module | ||
45 | public IUserProfilesService ServiceModule | ||
46 | { | ||
47 | get; private set; | ||
48 | } | ||
49 | |||
50 | // The HTTP server. | ||
51 | public IHttpServer Server | ||
52 | { | ||
53 | get; private set; | ||
54 | } | ||
55 | |||
56 | public string ConfigName | ||
57 | { | ||
58 | get; private set; | ||
59 | } | ||
60 | |||
61 | public bool Enabled | ||
62 | { | ||
63 | get; private set; | ||
64 | } | ||
65 | |||
66 | public UserProfilesConnector(IConfigSource config, IHttpServer server, string configName) : | ||
67 | base(config, server, configName) | ||
68 | { | ||
69 | ConfigName = "UserProfilesService"; | ||
70 | if(!string.IsNullOrEmpty(configName)) | ||
71 | ConfigName = configName; | ||
72 | |||
73 | IConfig serverConfig = config.Configs[ConfigName]; | ||
74 | if (serverConfig == null) | ||
75 | throw new Exception(String.Format("No section {0} in config file", ConfigName)); | ||
76 | |||
77 | if(!serverConfig.GetBoolean("Enabled",false)) | ||
78 | { | ||
79 | Enabled = false; | ||
80 | return; | ||
81 | } | ||
82 | |||
83 | Enabled = true; | ||
84 | |||
85 | Server = server; | ||
86 | |||
87 | string service = serverConfig.GetString("LocalServiceModule", String.Empty); | ||
88 | |||
89 | Object[] args = new Object[] { config, ConfigName }; | ||
90 | ServiceModule = ServerUtils.LoadPlugin<IUserProfilesService>(service, args); | ||
91 | |||
92 | JsonRpcProfileHandlers handler = new JsonRpcProfileHandlers(ServiceModule); | ||
93 | |||
94 | Server.AddJsonRPCHandler("avatarclassifiedsrequest", handler.AvatarClassifiedsRequest); | ||
95 | Server.AddJsonRPCHandler("classified_update", handler.ClassifiedUpdate); | ||
96 | Server.AddJsonRPCHandler("classifieds_info_query", handler.ClassifiedInfoRequest); | ||
97 | Server.AddJsonRPCHandler("classified_delete", handler.ClassifiedDelete); | ||
98 | Server.AddJsonRPCHandler("avatarpicksrequest", handler.AvatarPicksRequest); | ||
99 | Server.AddJsonRPCHandler("pickinforequest", handler.PickInfoRequest); | ||
100 | Server.AddJsonRPCHandler("picks_update", handler.PicksUpdate); | ||
101 | Server.AddJsonRPCHandler("picks_delete", handler.PicksDelete); | ||
102 | Server.AddJsonRPCHandler("avatarnotesrequest", handler.AvatarNotesRequest); | ||
103 | Server.AddJsonRPCHandler("avatar_notes_update", handler.NotesUpdate); | ||
104 | Server.AddJsonRPCHandler("avatar_properties_request", handler.AvatarPropertiesRequest); | ||
105 | Server.AddJsonRPCHandler("avatar_properties_update", handler.AvatarPropertiesUpdate); | ||
106 | Server.AddJsonRPCHandler("avatar_interests_update", handler.AvatarInterestsUpdate); | ||
107 | Server.AddJsonRPCHandler("image_assets_request", handler.AvatarImageAssetsRequest); | ||
108 | Server.AddJsonRPCHandler("user_data_request", handler.RequestUserAppData); | ||
109 | Server.AddJsonRPCHandler("user_data_update", handler.UpdateUserAppData); | ||
110 | } | ||
111 | } | ||
112 | } \ No newline at end of file | ||
diff --git a/OpenSim/Server/Handlers/Profiles/UserProfilesHandlers.cs b/OpenSim/Server/Handlers/Profiles/UserProfilesHandlers.cs new file mode 100644 index 0000000..f5f0794 --- /dev/null +++ b/OpenSim/Server/Handlers/Profiles/UserProfilesHandlers.cs | |||
@@ -0,0 +1,461 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Reflection; | ||
30 | using OpenMetaverse; | ||
31 | using OpenMetaverse.StructuredData; | ||
32 | using log4net; | ||
33 | using OpenSim.Services.Interfaces; | ||
34 | using OpenSim.Framework.Servers.HttpServer; | ||
35 | using OpenSim.Framework; | ||
36 | |||
37 | namespace OpenSim.Server.Handlers | ||
38 | { | ||
39 | public class UserProfilesHandlers | ||
40 | { | ||
41 | public UserProfilesHandlers () | ||
42 | { | ||
43 | } | ||
44 | } | ||
45 | |||
46 | public class JsonRpcProfileHandlers | ||
47 | { | ||
48 | static readonly ILog m_log = | ||
49 | LogManager.GetLogger( | ||
50 | MethodBase.GetCurrentMethod().DeclaringType); | ||
51 | |||
52 | public IUserProfilesService Service | ||
53 | { | ||
54 | get; private set; | ||
55 | } | ||
56 | |||
57 | public JsonRpcProfileHandlers(IUserProfilesService service) | ||
58 | { | ||
59 | Service = service; | ||
60 | } | ||
61 | |||
62 | #region Classifieds | ||
63 | /// <summary> | ||
64 | /// Request avatar's classified ads. | ||
65 | /// </summary> | ||
66 | /// <returns> | ||
67 | /// An array containing all the calassified uuid and it's name created by the creator id | ||
68 | /// </returns> | ||
69 | /// <param name='json'> | ||
70 | /// Our parameters are in the OSDMap json["params"] | ||
71 | /// </param> | ||
72 | /// <param name='response'> | ||
73 | /// If set to <c>true</c> response. | ||
74 | /// </param> | ||
75 | public bool AvatarClassifiedsRequest(OSDMap json, ref JsonRpcResponse response) | ||
76 | { | ||
77 | if(!json.ContainsKey("params")) | ||
78 | { | ||
79 | response.Error.Code = ErrorCode.ParseError; | ||
80 | m_log.DebugFormat ("Classified Request"); | ||
81 | return false; | ||
82 | } | ||
83 | |||
84 | OSDMap request = (OSDMap)json["params"]; | ||
85 | UUID creatorId = new UUID(request["creatorId"].AsString()); | ||
86 | |||
87 | |||
88 | OSDArray data = (OSDArray) Service.AvatarClassifiedsRequest(creatorId); | ||
89 | response.Result = data; | ||
90 | |||
91 | return true; | ||
92 | } | ||
93 | |||
94 | public bool ClassifiedUpdate(OSDMap json, ref JsonRpcResponse response) | ||
95 | { | ||
96 | if(!json.ContainsKey("params")) | ||
97 | { | ||
98 | response.Error.Code = ErrorCode.ParseError; | ||
99 | response.Error.Message = "Error parsing classified update request"; | ||
100 | m_log.DebugFormat ("Classified Update Request"); | ||
101 | return false; | ||
102 | } | ||
103 | |||
104 | string result = string.Empty; | ||
105 | UserClassifiedAdd ad = new UserClassifiedAdd(); | ||
106 | object Ad = (object)ad; | ||
107 | OSD.DeserializeMembers(ref Ad, (OSDMap)json["params"]); | ||
108 | if(Service.ClassifiedUpdate(ad, ref result)) | ||
109 | { | ||
110 | response.Result = OSD.SerializeMembers(ad); | ||
111 | return true; | ||
112 | } | ||
113 | |||
114 | response.Error.Code = ErrorCode.InternalError; | ||
115 | response.Error.Message = string.Format("{0}", result); | ||
116 | return false; | ||
117 | } | ||
118 | |||
119 | public bool ClassifiedDelete(OSDMap json, ref JsonRpcResponse response) | ||
120 | { | ||
121 | if(!json.ContainsKey("params")) | ||
122 | { | ||
123 | response.Error.Code = ErrorCode.ParseError; | ||
124 | m_log.DebugFormat ("Classified Delete Request"); | ||
125 | return false; | ||
126 | } | ||
127 | |||
128 | OSDMap request = (OSDMap)json["params"]; | ||
129 | UUID classifiedId = new UUID(request["classifiedID"].AsString()); | ||
130 | |||
131 | OSDMap res = new OSDMap(); | ||
132 | res["result"] = OSD.FromString("success"); | ||
133 | response.Result = res; | ||
134 | |||
135 | return true; | ||
136 | |||
137 | } | ||
138 | |||
139 | public bool ClassifiedInfoRequest(OSDMap json, ref JsonRpcResponse response) | ||
140 | { | ||
141 | if(!json.ContainsKey("params")) | ||
142 | { | ||
143 | response.Error.Code = ErrorCode.ParseError; | ||
144 | response.Error.Message = "no parameters supplied"; | ||
145 | m_log.DebugFormat ("Classified Info Request"); | ||
146 | return false; | ||
147 | } | ||
148 | |||
149 | string result = string.Empty; | ||
150 | UserClassifiedAdd ad = new UserClassifiedAdd(); | ||
151 | object Ad = (object)ad; | ||
152 | OSD.DeserializeMembers(ref Ad, (OSDMap)json["params"]); | ||
153 | if(Service.ClassifiedInfoRequest(ref ad, ref result)) | ||
154 | { | ||
155 | response.Result = OSD.SerializeMembers(ad); | ||
156 | return true; | ||
157 | } | ||
158 | |||
159 | response.Error.Code = ErrorCode.InternalError; | ||
160 | response.Error.Message = string.Format("{0}", result); | ||
161 | return false; | ||
162 | } | ||
163 | #endregion Classifieds | ||
164 | |||
165 | #region Picks | ||
166 | public bool AvatarPicksRequest(OSDMap json, ref JsonRpcResponse response) | ||
167 | { | ||
168 | if(!json.ContainsKey("params")) | ||
169 | { | ||
170 | response.Error.Code = ErrorCode.ParseError; | ||
171 | m_log.DebugFormat ("Avatar Picks Request"); | ||
172 | return false; | ||
173 | } | ||
174 | |||
175 | OSDMap request = (OSDMap)json["params"]; | ||
176 | UUID creatorId = new UUID(request["creatorId"].AsString()); | ||
177 | |||
178 | |||
179 | OSDArray data = (OSDArray) Service.AvatarPicksRequest(creatorId); | ||
180 | response.Result = data; | ||
181 | |||
182 | return true; | ||
183 | } | ||
184 | |||
185 | public bool PickInfoRequest(OSDMap json, ref JsonRpcResponse response) | ||
186 | { | ||
187 | if(!json.ContainsKey("params")) | ||
188 | { | ||
189 | response.Error.Code = ErrorCode.ParseError; | ||
190 | response.Error.Message = "no parameters supplied"; | ||
191 | m_log.DebugFormat ("Avatar Picks Info Request"); | ||
192 | return false; | ||
193 | } | ||
194 | |||
195 | string result = string.Empty; | ||
196 | UserProfilePick pick = new UserProfilePick(); | ||
197 | object Pick = (object)pick; | ||
198 | OSD.DeserializeMembers(ref Pick, (OSDMap)json["params"]); | ||
199 | if(Service.PickInfoRequest(ref pick, ref result)) | ||
200 | { | ||
201 | response.Result = OSD.SerializeMembers(pick); | ||
202 | return true; | ||
203 | } | ||
204 | |||
205 | response.Error.Code = ErrorCode.InternalError; | ||
206 | response.Error.Message = string.Format("{0}", result); | ||
207 | return false; | ||
208 | } | ||
209 | |||
210 | public bool PicksUpdate(OSDMap json, ref JsonRpcResponse response) | ||
211 | { | ||
212 | if(!json.ContainsKey("params")) | ||
213 | { | ||
214 | response.Error.Code = ErrorCode.ParseError; | ||
215 | response.Error.Message = "no parameters supplied"; | ||
216 | m_log.DebugFormat ("Avatar Picks Update Request"); | ||
217 | return false; | ||
218 | } | ||
219 | |||
220 | string result = string.Empty; | ||
221 | UserProfilePick pick = new UserProfilePick(); | ||
222 | object Pick = (object)pick; | ||
223 | OSD.DeserializeMembers(ref Pick, (OSDMap)json["params"]); | ||
224 | if(Service.PicksUpdate(ref pick, ref result)) | ||
225 | { | ||
226 | response.Result = OSD.SerializeMembers(pick); | ||
227 | return true; | ||
228 | } | ||
229 | |||
230 | response.Error.Code = ErrorCode.InternalError; | ||
231 | response.Error.Message = "unable to update pick"; | ||
232 | |||
233 | return false; | ||
234 | } | ||
235 | |||
236 | public bool PicksDelete(OSDMap json, ref JsonRpcResponse response) | ||
237 | { | ||
238 | if(!json.ContainsKey("params")) | ||
239 | { | ||
240 | response.Error.Code = ErrorCode.ParseError; | ||
241 | m_log.DebugFormat ("Avatar Picks Delete Request"); | ||
242 | return false; | ||
243 | } | ||
244 | |||
245 | OSDMap request = (OSDMap)json["params"]; | ||
246 | UUID pickId = new UUID(request["pickId"].AsString()); | ||
247 | if(Service.PicksDelete(pickId)) | ||
248 | return true; | ||
249 | |||
250 | response.Error.Code = ErrorCode.InternalError; | ||
251 | response.Error.Message = "data error removing record"; | ||
252 | return false; | ||
253 | } | ||
254 | #endregion Picks | ||
255 | |||
256 | #region Notes | ||
257 | public bool AvatarNotesRequest(OSDMap json, ref JsonRpcResponse response) | ||
258 | { | ||
259 | if(!json.ContainsKey("params")) | ||
260 | { | ||
261 | response.Error.Code = ErrorCode.ParseError; | ||
262 | response.Error.Message = "Params missing"; | ||
263 | m_log.DebugFormat ("Avatar Notes Request"); | ||
264 | return false; | ||
265 | } | ||
266 | |||
267 | string result = string.Empty; | ||
268 | UserProfileNotes note = new UserProfileNotes(); | ||
269 | object Note = (object)note; | ||
270 | OSD.DeserializeMembers(ref Note, (OSDMap)json["params"]); | ||
271 | if(Service.AvatarNotesRequest(ref note)) | ||
272 | { | ||
273 | response.Result = OSD.SerializeMembers(note); | ||
274 | return true; | ||
275 | } | ||
276 | |||
277 | object Notes = (object) note; | ||
278 | OSD.DeserializeMembers(ref Notes, (OSDMap)json["params"]); | ||
279 | return true; | ||
280 | } | ||
281 | |||
282 | public bool NotesUpdate(OSDMap json, ref JsonRpcResponse response) | ||
283 | { | ||
284 | if(!json.ContainsKey("params")) | ||
285 | { | ||
286 | response.Error.Code = ErrorCode.ParseError; | ||
287 | response.Error.Message = "No parameters"; | ||
288 | m_log.DebugFormat ("Avatar Notes Update Request"); | ||
289 | return false; | ||
290 | } | ||
291 | |||
292 | string result = string.Empty; | ||
293 | UserProfileNotes note = new UserProfileNotes(); | ||
294 | object Notes = (object) note; | ||
295 | OSD.DeserializeMembers(ref Notes, (OSDMap)json["params"]); | ||
296 | if(Service.NotesUpdate(ref note, ref result)) | ||
297 | { | ||
298 | response.Result = OSD.SerializeMembers(note); | ||
299 | return true; | ||
300 | } | ||
301 | return true; | ||
302 | } | ||
303 | #endregion Notes | ||
304 | |||
305 | #region Profile Properties | ||
306 | public bool AvatarPropertiesRequest(OSDMap json, ref JsonRpcResponse response) | ||
307 | { | ||
308 | if(!json.ContainsKey("params")) | ||
309 | { | ||
310 | response.Error.Code = ErrorCode.ParseError; | ||
311 | response.Error.Message = "no parameters supplied"; | ||
312 | m_log.DebugFormat ("Avatar Properties Request"); | ||
313 | return false; | ||
314 | } | ||
315 | |||
316 | string result = string.Empty; | ||
317 | UserProfileProperties props = new UserProfileProperties(); | ||
318 | object Props = (object)props; | ||
319 | OSD.DeserializeMembers(ref Props, (OSDMap)json["params"]); | ||
320 | if(Service.AvatarPropertiesRequest(ref props, ref result)) | ||
321 | { | ||
322 | response.Result = OSD.SerializeMembers(props); | ||
323 | return true; | ||
324 | } | ||
325 | |||
326 | response.Error.Code = ErrorCode.InternalError; | ||
327 | response.Error.Message = string.Format("{0}", result); | ||
328 | return false; | ||
329 | } | ||
330 | |||
331 | public bool AvatarPropertiesUpdate(OSDMap json, ref JsonRpcResponse response) | ||
332 | { | ||
333 | if(!json.ContainsKey("params")) | ||
334 | { | ||
335 | response.Error.Code = ErrorCode.ParseError; | ||
336 | response.Error.Message = "no parameters supplied"; | ||
337 | m_log.DebugFormat ("Avatar Properties Update Request"); | ||
338 | return false; | ||
339 | } | ||
340 | |||
341 | string result = string.Empty; | ||
342 | UserProfileProperties props = new UserProfileProperties(); | ||
343 | object Props = (object)props; | ||
344 | OSD.DeserializeMembers(ref Props, (OSDMap)json["params"]); | ||
345 | if(Service.AvatarPropertiesUpdate(ref props, ref result)) | ||
346 | { | ||
347 | response.Result = OSD.SerializeMembers(props); | ||
348 | return true; | ||
349 | } | ||
350 | |||
351 | response.Error.Code = ErrorCode.InternalError; | ||
352 | response.Error.Message = string.Format("{0}", result); | ||
353 | return false; | ||
354 | } | ||
355 | #endregion Profile Properties | ||
356 | |||
357 | #region Interests | ||
358 | public bool AvatarInterestsUpdate(OSDMap json, ref JsonRpcResponse response) | ||
359 | { | ||
360 | if(!json.ContainsKey("params")) | ||
361 | { | ||
362 | response.Error.Code = ErrorCode.ParseError; | ||
363 | response.Error.Message = "no parameters supplied"; | ||
364 | m_log.DebugFormat ("Avatar Interests Update Request"); | ||
365 | return false; | ||
366 | } | ||
367 | |||
368 | string result = string.Empty; | ||
369 | UserProfileProperties props = new UserProfileProperties(); | ||
370 | object Props = (object)props; | ||
371 | OSD.DeserializeMembers(ref Props, (OSDMap)json["params"]); | ||
372 | if(Service.AvatarInterestsUpdate(props, ref result)) | ||
373 | { | ||
374 | response.Result = OSD.SerializeMembers(props); | ||
375 | return true; | ||
376 | } | ||
377 | |||
378 | response.Error.Code = ErrorCode.InternalError; | ||
379 | response.Error.Message = string.Format("{0}", result); | ||
380 | return false; | ||
381 | } | ||
382 | #endregion Interests | ||
383 | |||
384 | #region Utility | ||
385 | public bool AvatarImageAssetsRequest(OSDMap json, ref JsonRpcResponse response) | ||
386 | { | ||
387 | if(!json.ContainsKey("params")) | ||
388 | { | ||
389 | response.Error.Code = ErrorCode.ParseError; | ||
390 | m_log.DebugFormat ("Avatar Image Assets Request"); | ||
391 | return false; | ||
392 | } | ||
393 | |||
394 | OSDMap request = (OSDMap)json["params"]; | ||
395 | UUID avatarId = new UUID(request["avatarId"].AsString()); | ||
396 | |||
397 | OSDArray data = (OSDArray) Service.AvatarImageAssetsRequest(avatarId); | ||
398 | response.Result = data; | ||
399 | |||
400 | return true; | ||
401 | } | ||
402 | #endregion Utiltiy | ||
403 | |||
404 | #region UserData | ||
405 | public bool RequestUserAppData(OSDMap json, ref JsonRpcResponse response) | ||
406 | { | ||
407 | if(!json.ContainsKey("params")) | ||
408 | { | ||
409 | response.Error.Code = ErrorCode.ParseError; | ||
410 | response.Error.Message = "no parameters supplied"; | ||
411 | m_log.DebugFormat ("User Application Service URL Request: No Parameters!"); | ||
412 | return false; | ||
413 | } | ||
414 | |||
415 | string result = string.Empty; | ||
416 | UserAppData props = new UserAppData(); | ||
417 | object Props = (object)props; | ||
418 | OSD.DeserializeMembers(ref Props, (OSDMap)json["params"]); | ||
419 | if(Service.RequestUserAppData(ref props, ref result)) | ||
420 | { | ||
421 | OSDMap res = new OSDMap(); | ||
422 | res["result"] = OSD.FromString("success"); | ||
423 | res["token"] = OSD.FromString (result); | ||
424 | response.Result = res; | ||
425 | |||
426 | return true; | ||
427 | } | ||
428 | |||
429 | response.Error.Code = ErrorCode.InternalError; | ||
430 | response.Error.Message = string.Format("{0}", result); | ||
431 | return false; | ||
432 | } | ||
433 | |||
434 | public bool UpdateUserAppData(OSDMap json, ref JsonRpcResponse response) | ||
435 | { | ||
436 | if(!json.ContainsKey("params")) | ||
437 | { | ||
438 | response.Error.Code = ErrorCode.ParseError; | ||
439 | response.Error.Message = "no parameters supplied"; | ||
440 | m_log.DebugFormat ("User App Data Update Request"); | ||
441 | return false; | ||
442 | } | ||
443 | |||
444 | string result = string.Empty; | ||
445 | UserAppData props = new UserAppData(); | ||
446 | object Props = (object)props; | ||
447 | OSD.DeserializeMembers(ref Props, (OSDMap)json["params"]); | ||
448 | if(Service.SetUserAppData(props, ref result)) | ||
449 | { | ||
450 | response.Result = OSD.SerializeMembers(props); | ||
451 | return true; | ||
452 | } | ||
453 | |||
454 | response.Error.Code = ErrorCode.InternalError; | ||
455 | response.Error.Message = string.Format("{0}", result); | ||
456 | return false; | ||
457 | } | ||
458 | #endregion UserData | ||
459 | } | ||
460 | } | ||
461 | |||