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