aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Grid/UserServer/IUGAIMCore.cs43
-rw-r--r--OpenSim/Grid/UserServer/Main.cs179
-rw-r--r--OpenSim/Grid/UserServer/MessageServersConnector.cs26
-rw-r--r--OpenSim/Grid/UserServer/UserLoginService.cs26
-rw-r--r--OpenSim/Grid/UserServer/UserManager.cs187
-rw-r--r--OpenSim/Grid/UserServer/UserServerAvatarAppearanceModule.cs124
-rw-r--r--OpenSim/Grid/UserServer/UserServerFriendsModule.cs173
7 files changed, 529 insertions, 229 deletions
diff --git a/OpenSim/Grid/UserServer/IUGAIMCore.cs b/OpenSim/Grid/UserServer/IUGAIMCore.cs
new file mode 100644
index 0000000..0783fe5
--- /dev/null
+++ b/OpenSim/Grid/UserServer/IUGAIMCore.cs
@@ -0,0 +1,43 @@
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
28using System;
29using System.Collections.Generic;
30using System.Text;
31using OpenSim.Framework.Servers;
32
33namespace OpenSim.Grid.UserServer
34{
35 public interface IUGAIMCore
36 {
37 T Get<T>();
38 void RegisterInterface<T>(T iface);
39 bool TryGet<T>(out T iface);
40 BaseHttpServer GetHttpServer();
41
42 }
43}
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs
index 1e6504d..efa090e 100644
--- a/OpenSim/Grid/UserServer/Main.cs
+++ b/OpenSim/Grid/UserServer/Main.cs
@@ -46,7 +46,7 @@ namespace OpenSim.Grid.UserServer
46 /// <summary> 46 /// <summary>
47 /// Grid user server main class 47 /// Grid user server main class
48 /// </summary> 48 /// </summary>
49 public class OpenUser_Main : BaseOpenSimServer 49 public class OpenUser_Main : BaseOpenSimServer, IUGAIMCore
50 { 50 {
51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52 52
@@ -55,6 +55,10 @@ namespace OpenSim.Grid.UserServer
55 protected UserDataBaseService m_userDataBaseService; 55 protected UserDataBaseService m_userDataBaseService;
56 56
57 public UserManager m_userManager; 57 public UserManager m_userManager;
58
59 protected UserServerAvatarAppearanceModule m_avatarAppearanceModule;
60 protected UserServerFriendsModule m_friendsModule;
61
58 public UserLoginService m_loginService; 62 public UserLoginService m_loginService;
59 public GridInfoService m_gridInfoService; 63 public GridInfoService m_gridInfoService;
60 public MessageServersConnector m_messagesService; 64 public MessageServersConnector m_messagesService;
@@ -99,17 +103,64 @@ namespace OpenSim.Grid.UserServer
99 103
100 IInterServiceInventoryServices inventoryService = new OGS1InterServiceInventoryService(Cfg.InventoryUrl); 104 IInterServiceInventoryServices inventoryService = new OGS1InterServiceInventoryService(Cfg.InventoryUrl);
101 105
106 //setup database access service
102 m_userDataBaseService = new UserDataBaseService(inventoryService); 107 m_userDataBaseService = new UserDataBaseService(inventoryService);
103 m_userDataBaseService.AddPlugin(Cfg.DatabaseProvider, Cfg.DatabaseConnect); 108 m_userDataBaseService.AddPlugin(Cfg.DatabaseProvider, Cfg.DatabaseConnect);
104 109
105 StartupUserManager(inventoryService); 110 //Register the database access service so modules can fetch it
111 // RegisterInterface<UserDataBaseService>(m_userDataBaseService);
112
113 //setup services/modules
114 StartupUserServerModules();
106 115
107 m_gridInfoService = new GridInfoService(); 116 m_gridInfoService = new GridInfoService();
108 117
109 StartupLoginService(inventoryService); 118 StartupLoginService(inventoryService);
119 //
120 // Get the minimum defaultLevel to access to the grid
121 //
122 m_loginService.setloginlevel((int)Cfg.DefaultUserLevel);
110 123
111 m_messagesService = new MessageServersConnector(); 124 m_messagesService = new MessageServersConnector();
112 125
126 //register event handlers
127 RegisterEventHandlers();
128
129 //register http handlers and start http server
130 m_log.Info("[STARTUP]: Starting HTTP process");
131 m_httpServer = new BaseHttpServer(Cfg.HttpPort);
132 RegisterHttpHandlers();
133 m_httpServer.Start();
134
135 base.StartupSpecific();
136
137 //register Console command handlers
138 RegisterConsoleCommands();
139 }
140
141 /// <summary>
142 /// Start up the user manager
143 /// </summary>
144 /// <param name="inventoryService"></param>
145 protected virtual void StartupUserServerModules()
146 {
147 m_userManager = new UserManager(m_userDataBaseService);
148 m_avatarAppearanceModule = new UserServerAvatarAppearanceModule(m_userDataBaseService);
149 m_friendsModule = new UserServerFriendsModule(m_userDataBaseService);
150 }
151
152 /// <summary>
153 /// Start up the login service
154 /// </summary>
155 /// <param name="inventoryService"></param>
156 protected virtual void StartupLoginService(IInterServiceInventoryServices inventoryService)
157 {
158 m_loginService = new UserLoginService(
159 m_userDataBaseService, inventoryService, new LibraryRootFolder(Cfg.LibraryXmlfile), Cfg, Cfg.DefaultStartupMsg, new RegionProfileServiceProxy());
160 }
161
162 protected virtual void RegisterEventHandlers()
163 {
113 m_loginService.OnUserLoggedInAtLocation += NotifyMessageServersUserLoggedInToLocation; 164 m_loginService.OnUserLoggedInAtLocation += NotifyMessageServersUserLoggedInToLocation;
114 m_userManager.OnLogOffUser += NotifyMessageServersUserLoggOff; 165 m_userManager.OnLogOffUser += NotifyMessageServersUserLoggOff;
115 166
@@ -117,15 +168,10 @@ namespace OpenSim.Grid.UserServer
117 m_messagesService.OnAgentLeaving += HandleAgentLeaving; 168 m_messagesService.OnAgentLeaving += HandleAgentLeaving;
118 m_messagesService.OnRegionStartup += HandleRegionStartup; 169 m_messagesService.OnRegionStartup += HandleRegionStartup;
119 m_messagesService.OnRegionShutdown += HandleRegionShutdown; 170 m_messagesService.OnRegionShutdown += HandleRegionShutdown;
171 }
120 172
121 m_log.Info("[STARTUP]: Starting HTTP process"); 173 protected virtual void RegisterConsoleCommands()
122 174 {
123 m_httpServer = new BaseHttpServer(Cfg.HttpPort);
124 AddHttpHandlers();
125 m_httpServer.Start();
126
127 base.StartupSpecific();
128
129 m_console.Commands.AddCommand("userserver", false, "create user", 175 m_console.Commands.AddCommand("userserver", false, "create user",
130 "create user [<first> [<last> [<x> <y> [email]]]]", 176 "create user [<first> [<last> [<x> <y> [email]]]]",
131 "Create a new user account", RunCommand); 177 "Create a new user account", RunCommand);
@@ -156,80 +202,67 @@ namespace OpenSim.Grid.UserServer
156 "Log off a named user", RunCommand); 202 "Log off a named user", RunCommand);
157 } 203 }
158 204
159 /// <summary> 205 protected virtual void RegisterHttpHandlers()
160 /// Start up the user manager
161 /// </summary>
162 /// <param name="inventoryService"></param>
163 protected virtual void StartupUserManager(IInterServiceInventoryServices inventoryService)
164 { 206 {
165 m_userManager = new UserManager(inventoryService, m_userDataBaseService); 207 m_loginService.RegisterHandlers(m_httpServer, Cfg.EnableLLSDLogin, true);
208
209 m_userManager.RegisterHandlers(m_httpServer);
210 m_friendsModule.RegisterHandlers(m_httpServer);
211 m_avatarAppearanceModule.RegisterHandlers(m_httpServer);
212 m_messagesService.RegisterHandlers(m_httpServer);
213
214 m_httpServer.AddStreamHandler(new RestStreamHandler("GET", "/get_grid_info",
215 m_gridInfoService.RestGetGridInfoMethod));
216 m_httpServer.AddXmlRPCHandler("get_grid_info", m_gridInfoService.XmlRpcGridInfoMethod);
166 } 217 }
167 218
219 public override void ShutdownSpecific()
220 {
221 m_loginService.OnUserLoggedInAtLocation -= NotifyMessageServersUserLoggedInToLocation;
222 }
223
224 #region IUGAIMCore
225 private readonly Dictionary<Type, object> m_moduleInterfaces = new Dictionary<Type, object>();
226
168 /// <summary> 227 /// <summary>
169 /// Start up the login service 228 /// Register an Module interface.
170 /// </summary> 229 /// </summary>
171 /// <param name="inventoryService"></param> 230 /// <typeparam name="T"></typeparam>
172 protected virtual void StartupLoginService(IInterServiceInventoryServices inventoryService) 231 /// <param name="iface"></param>
232 public void RegisterInterface<T>(T iface)
173 { 233 {
174 m_loginService = new UserLoginService( 234 lock (m_moduleInterfaces)
175 m_userDataBaseService, inventoryService, new LibraryRootFolder(Cfg.LibraryXmlfile), Cfg, Cfg.DefaultStartupMsg, new RegionProfileServiceProxy()); 235 {
236 if (!m_moduleInterfaces.ContainsKey(typeof(T)))
237 {
238 m_moduleInterfaces.Add(typeof(T), iface);
239 }
240 }
176 } 241 }
177 242
178 protected virtual void AddHttpHandlers() 243 public bool TryGet<T>(out T iface)
179 { 244 {
180 m_httpServer.AddXmlRPCHandler("login_to_simulator", m_loginService.XmlRpcLoginMethod); 245 if (m_moduleInterfaces.ContainsKey(typeof(T)))
181
182 m_httpServer.AddHTTPHandler("login", m_loginService.ProcessHTMLLogin);
183 //
184 // Get the minimum defaultLevel to access to the grid
185 //
186 m_loginService.setloginlevel((int)Cfg.DefaultUserLevel);
187
188 if (Cfg.EnableLLSDLogin)
189 { 246 {
190 m_httpServer.SetDefaultLLSDHandler(m_loginService.LLSDLoginMethod); 247 iface = (T)m_moduleInterfaces[typeof(T)];
248 return true;
191 } 249 }
250 iface = default(T);
251 return false;
252 }
192 253
193 m_httpServer.AddXmlRPCHandler("get_user_by_name", m_userManager.XmlRPCGetUserMethodName); 254 public T Get<T>()
194 m_httpServer.AddXmlRPCHandler("get_user_by_uuid", m_userManager.XmlRPCGetUserMethodUUID); 255 {
195 m_httpServer.AddXmlRPCHandler("get_avatar_picker_avatar", m_userManager.XmlRPCGetAvatarPickerAvatar); 256 return (T)m_moduleInterfaces[typeof(T)];
196 m_httpServer.AddXmlRPCHandler("add_new_user_friend", m_userManager.XmlRpcResponseXmlRPCAddUserFriend); 257 }
197 m_httpServer.AddXmlRPCHandler("remove_user_friend", m_userManager.XmlRpcResponseXmlRPCRemoveUserFriend);
198 m_httpServer.AddXmlRPCHandler("update_user_friend_perms",
199 m_userManager.XmlRpcResponseXmlRPCUpdateUserFriendPerms);
200 m_httpServer.AddXmlRPCHandler("get_user_friend_list", m_userManager.XmlRpcResponseXmlRPCGetUserFriendList);
201 m_httpServer.AddXmlRPCHandler("get_avatar_appearance", m_userManager.XmlRPCGetAvatarAppearance);
202 m_httpServer.AddXmlRPCHandler("update_avatar_appearance", m_userManager.XmlRPCUpdateAvatarAppearance);
203 m_httpServer.AddXmlRPCHandler("update_user_current_region", m_userManager.XmlRPCAtRegion);
204 m_httpServer.AddXmlRPCHandler("logout_of_simulator", m_userManager.XmlRPCLogOffUserMethodUUID);
205 m_httpServer.AddXmlRPCHandler("get_agent_by_uuid", m_userManager.XmlRPCGetAgentMethodUUID);
206 m_httpServer.AddXmlRPCHandler("check_auth_session", m_userManager.XmlRPCCheckAuthSession);
207 m_httpServer.AddXmlRPCHandler("set_login_params", m_loginService.XmlRPCSetLoginParams);
208 m_httpServer.AddXmlRPCHandler("region_startup", m_messagesService.RegionStartup);
209 m_httpServer.AddXmlRPCHandler("region_shutdown", m_messagesService.RegionShutdown);
210 m_httpServer.AddXmlRPCHandler("agent_location", m_messagesService.AgentLocation);
211 m_httpServer.AddXmlRPCHandler("agent_leaving", m_messagesService.AgentLeaving);
212 // Message Server ---> User Server
213 m_httpServer.AddXmlRPCHandler("register_messageserver", m_messagesService.XmlRPCRegisterMessageServer);
214 m_httpServer.AddXmlRPCHandler("agent_change_region", m_messagesService.XmlRPCUserMovedtoRegion);
215 m_httpServer.AddXmlRPCHandler("deregister_messageserver", m_messagesService.XmlRPCDeRegisterMessageServer);
216
217 m_httpServer.AddStreamHandler(new RestStreamHandler("GET", "/get_grid_info",
218 m_gridInfoService.RestGetGridInfoMethod));
219 m_httpServer.AddXmlRPCHandler("get_grid_info", m_gridInfoService.XmlRpcGridInfoMethod);
220
221 m_httpServer.AddStreamHandler(
222 new RestStreamHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod));
223
224 m_httpServer.AddXmlRPCHandler("update_user_profile", m_userManager.XmlRpcResponseXmlRPCUpdateUserProfile);
225 258
226 // Handler for OpenID avatar identity pages 259 public BaseHttpServer GetHttpServer()
227 m_httpServer.AddStreamHandler(new OpenIdStreamHandler("GET", "/users/", m_loginService)); 260 {
228 // Handlers for the OpenID endpoint server 261 return m_httpServer;
229 m_httpServer.AddStreamHandler(new OpenIdStreamHandler("POST", "/openid/server/", m_loginService));
230 m_httpServer.AddStreamHandler(new OpenIdStreamHandler("GET", "/openid/server/", m_loginService));
231 } 262 }
263 #endregion
232 264
265 #region Console Command Handlers
233 public void do_create(string[] args) 266 public void do_create(string[] args)
234 { 267 {
235 switch (args[0]) 268 switch (args[0])
@@ -468,19 +501,16 @@ namespace OpenSim.Grid.UserServer
468 m_console.Notice("login-level <value> - Set the miminim userlevel allowed To login."); 501 m_console.Notice("login-level <value> - Set the miminim userlevel allowed To login.");
469 m_console.Notice("login-reset - reset the login level to its default value."); 502 m_console.Notice("login-reset - reset the login level to its default value.");
470 m_console.Notice("login-text <text to print during the login>"); 503 m_console.Notice("login-text <text to print during the login>");
471
472 }
473 504
474 public override void ShutdownSpecific()
475 {
476 m_loginService.OnUserLoggedInAtLocation -= NotifyMessageServersUserLoggedInToLocation;
477 } 505 }
506 #endregion
478 507
479 public void TestResponse(List<InventoryFolderBase> resp) 508 public void TestResponse(List<InventoryFolderBase> resp)
480 { 509 {
481 m_console.Notice("response got"); 510 m_console.Notice("response got");
482 } 511 }
483 512
513 #region Event Handlers
484 public void NotifyMessageServersUserLoggOff(UUID agentID) 514 public void NotifyMessageServersUserLoggOff(UUID agentID)
485 { 515 {
486 m_messagesService.TellMessageServersAboutUserLogoff(agentID); 516 m_messagesService.TellMessageServersAboutUserLogoff(agentID);
@@ -531,5 +561,6 @@ namespace OpenSim.Grid.UserServer
531 m_userManager.HandleRegionShutdown(regionID); 561 m_userManager.HandleRegionShutdown(regionID);
532 m_messagesService.TellMessageServersAboutRegionShutdown(regionID); 562 m_messagesService.TellMessageServersAboutRegionShutdown(regionID);
533 } 563 }
564 #endregion
534 } 565 }
535} 566}
diff --git a/OpenSim/Grid/UserServer/MessageServersConnector.cs b/OpenSim/Grid/UserServer/MessageServersConnector.cs
index 8d16109..1d0649c 100644
--- a/OpenSim/Grid/UserServer/MessageServersConnector.cs
+++ b/OpenSim/Grid/UserServer/MessageServersConnector.cs
@@ -71,6 +71,8 @@ namespace OpenSim.Grid.UserServer
71 71
72 public Dictionary<string, MessageServerInfo> MessageServers; 72 public Dictionary<string, MessageServerInfo> MessageServers;
73 73
74 private BaseHttpServer m_httpServer;
75
74 private BlockingQueue<PresenceNotification> m_NotifyQueue = 76 private BlockingQueue<PresenceNotification> m_NotifyQueue =
75 new BlockingQueue<PresenceNotification>(); 77 new BlockingQueue<PresenceNotification>();
76 78
@@ -88,6 +90,30 @@ namespace OpenSim.Grid.UserServer
88 m_NotifyThread.Start(); 90 m_NotifyThread.Start();
89 } 91 }
90 92
93 public void Initialise()
94 {
95
96 }
97
98 public void PostInitialise()
99 {
100
101 }
102
103 public void RegisterHandlers(BaseHttpServer httpServer)
104 {
105 m_httpServer = httpServer;
106
107 m_httpServer.AddXmlRPCHandler("region_startup", RegionStartup);
108 m_httpServer.AddXmlRPCHandler("region_shutdown", RegionShutdown);
109 m_httpServer.AddXmlRPCHandler("agent_location", AgentLocation);
110 m_httpServer.AddXmlRPCHandler("agent_leaving", AgentLeaving);
111 // Message Server ---> User Server
112 m_httpServer.AddXmlRPCHandler("register_messageserver", XmlRPCRegisterMessageServer);
113 m_httpServer.AddXmlRPCHandler("agent_change_region", XmlRPCUserMovedtoRegion);
114 m_httpServer.AddXmlRPCHandler("deregister_messageserver", XmlRPCDeRegisterMessageServer);
115 }
116
91 public void RegisterMessageServer(string URI, MessageServerInfo serverData) 117 public void RegisterMessageServer(string URI, MessageServerInfo serverData)
92 { 118 {
93 lock (MessageServers) 119 lock (MessageServers)
diff --git a/OpenSim/Grid/UserServer/UserLoginService.cs b/OpenSim/Grid/UserServer/UserLoginService.cs
index 0bec2a1..0cb4976 100644
--- a/OpenSim/Grid/UserServer/UserLoginService.cs
+++ b/OpenSim/Grid/UserServer/UserLoginService.cs
@@ -38,6 +38,7 @@ using OpenSim.Framework;
38using OpenSim.Framework.Communications; 38using OpenSim.Framework.Communications;
39using OpenSim.Framework.Communications.Cache; 39using OpenSim.Framework.Communications.Cache;
40using OpenSim.Framework.Communications.Capabilities; 40using OpenSim.Framework.Communications.Capabilities;
41using OpenSim.Framework.Servers;
41 42
42namespace OpenSim.Grid.UserServer 43namespace OpenSim.Grid.UserServer
43{ 44{
@@ -61,6 +62,8 @@ namespace OpenSim.Grid.UserServer
61 public UserConfig m_config; 62 public UserConfig m_config;
62 private readonly IRegionProfileService m_regionProfileService; 63 private readonly IRegionProfileService m_regionProfileService;
63 64
65 protected BaseHttpServer m_httpServer;
66
64 public UserLoginService( 67 public UserLoginService(
65 UserManagerBase userManager, IInterServiceInventoryServices inventoryService, 68 UserManagerBase userManager, IInterServiceInventoryServices inventoryService,
66 LibraryRootFolder libraryRootFolder, 69 LibraryRootFolder libraryRootFolder,
@@ -71,6 +74,29 @@ namespace OpenSim.Grid.UserServer
71 m_inventoryService = inventoryService; 74 m_inventoryService = inventoryService;
72 m_regionProfileService = regionProfileService; 75 m_regionProfileService = regionProfileService;
73 } 76 }
77
78 public void RegisterHandlers(BaseHttpServer httpServer, bool registerLLSDHandler, bool registerOpenIDHandlers)
79 {
80 m_httpServer = httpServer;
81
82 m_httpServer.AddXmlRPCHandler("login_to_simulator", XmlRpcLoginMethod);
83 m_httpServer.AddHTTPHandler("login", ProcessHTMLLogin);
84 m_httpServer.AddXmlRPCHandler("set_login_params", XmlRPCSetLoginParams);
85
86 if (registerLLSDHandler)
87 {
88 m_httpServer.SetDefaultLLSDHandler(LLSDLoginMethod);
89 }
90
91 if (registerOpenIDHandlers)
92 {
93 // Handler for OpenID avatar identity pages
94 m_httpServer.AddStreamHandler(new OpenIdStreamHandler("GET", "/users/", this));
95 // Handlers for the OpenID endpoint server
96 m_httpServer.AddStreamHandler(new OpenIdStreamHandler("POST", "/openid/server/", this));
97 m_httpServer.AddStreamHandler(new OpenIdStreamHandler("GET", "/openid/server/", this));
98 }
99 }
74 100
75 public void setloginlevel(int level) 101 public void setloginlevel(int level)
76 { 102 {
diff --git a/OpenSim/Grid/UserServer/UserManager.cs b/OpenSim/Grid/UserServer/UserManager.cs
index 6229dec..ca50421 100644
--- a/OpenSim/Grid/UserServer/UserManager.cs
+++ b/OpenSim/Grid/UserServer/UserManager.cs
@@ -48,16 +48,45 @@ namespace OpenSim.Grid.UserServer
48 private logOffUser handlerLogOffUser; 48 private logOffUser handlerLogOffUser;
49 49
50 private UserDataBaseService m_userDataBaseService; 50 private UserDataBaseService m_userDataBaseService;
51 private BaseHttpServer m_httpServer;
51 52
52 /// <summary> 53 /// <summary>
53 /// Constructor 54 ///
54 /// </summary> 55 /// </summary>
55 /// <param name="interServiceInventoryService"></param> 56 /// <param name="userDataBaseService"></param>
56 public UserManager(IInterServiceInventoryServices interServiceInventoryService, UserDataBaseService userDataBaseService) 57 public UserManager( UserDataBaseService userDataBaseService)
57 { 58 {
58 m_userDataBaseService = userDataBaseService; 59 m_userDataBaseService = userDataBaseService;
59 } 60 }
60 61
62 public void Initialise()
63 {
64
65 }
66
67 public void PostInitialise()
68 {
69
70 }
71
72 public void RegisterHandlers(BaseHttpServer httpServer)
73 {
74 m_httpServer = httpServer;
75
76 m_httpServer.AddXmlRPCHandler("get_user_by_name", XmlRPCGetUserMethodName);
77 m_httpServer.AddXmlRPCHandler("get_user_by_uuid", XmlRPCGetUserMethodUUID);
78 m_httpServer.AddXmlRPCHandler("get_avatar_picker_avatar", XmlRPCGetAvatarPickerAvatar);
79
80 m_httpServer.AddXmlRPCHandler("update_user_current_region", XmlRPCAtRegion);
81 m_httpServer.AddXmlRPCHandler("logout_of_simulator", XmlRPCLogOffUserMethodUUID);
82 m_httpServer.AddXmlRPCHandler("get_agent_by_uuid", XmlRPCGetAgentMethodUUID);
83 m_httpServer.AddXmlRPCHandler("check_auth_session", XmlRPCCheckAuthSession);
84
85 m_httpServer.AddXmlRPCHandler("update_user_profile", XmlRpcResponseXmlRPCUpdateUserProfile);
86
87 m_httpServer.AddStreamHandler(new RestStreamHandler("DELETE", "/usersessions/", RestDeleteUserSessionMethod));
88 }
89
61 /// <summary> 90 /// <summary>
62 /// Deletes an active agent session 91 /// Deletes an active agent session
63 /// </summary> 92 /// </summary>
@@ -109,26 +138,6 @@ namespace OpenSim.Grid.UserServer
109 return response; 138 return response;
110 } 139 }
111 140
112 public XmlRpcResponse FriendListItemListtoXmlRPCResponse(List<FriendListItem> returnUsers)
113 {
114 XmlRpcResponse response = new XmlRpcResponse();
115 Hashtable responseData = new Hashtable();
116 // Query Result Information
117
118 responseData["avcount"] = returnUsers.Count.ToString();
119
120 for (int i = 0; i < returnUsers.Count; i++)
121 {
122 responseData["ownerID" + i] = returnUsers[i].FriendListOwner.ToString();
123 responseData["friendID" + i] = returnUsers[i].Friend.ToString();
124 responseData["ownerPerms" + i] = returnUsers[i].FriendListOwnerPerms.ToString();
125 responseData["friendPerms" + i] = returnUsers[i].FriendPerms.ToString();
126 }
127 response.Value = responseData;
128
129 return response;
130 }
131
132 /// <summary> 141 /// <summary>
133 /// Converts a user profile to an XML element which can be returned 142 /// Converts a user profile to an XML element which can be returned
134 /// </summary> 143 /// </summary>
@@ -230,138 +239,6 @@ namespace OpenSim.Grid.UserServer
230 return response; 239 return response;
231 } 240 }
232 241
233 public XmlRpcResponse XmlRpcResponseXmlRPCAddUserFriend(XmlRpcRequest request)
234 {
235 XmlRpcResponse response = new XmlRpcResponse();
236 Hashtable requestData = (Hashtable) request.Params[0];
237 Hashtable responseData = new Hashtable();
238 string returnString = "FALSE";
239 // Query Result Information
240
241 if (requestData.Contains("ownerID") && requestData.Contains("friendID") &&
242 requestData.Contains("friendPerms"))
243 {
244 // UserManagerBase.AddNewuserFriend
245 m_userDataBaseService.AddNewUserFriend(new UUID((string)requestData["ownerID"]),
246 new UUID((string) requestData["friendID"]),
247 (uint) Convert.ToInt32((string) requestData["friendPerms"]));
248 returnString = "TRUE";
249 }
250 responseData["returnString"] = returnString;
251 response.Value = responseData;
252 return response;
253 }
254
255 public XmlRpcResponse XmlRpcResponseXmlRPCRemoveUserFriend(XmlRpcRequest request)
256 {
257 XmlRpcResponse response = new XmlRpcResponse();
258 Hashtable requestData = (Hashtable) request.Params[0];
259 Hashtable responseData = new Hashtable();
260 string returnString = "FALSE";
261 // Query Result Information
262
263 if (requestData.Contains("ownerID") && requestData.Contains("friendID"))
264 {
265 // UserManagerBase.AddNewuserFriend
266 m_userDataBaseService.RemoveUserFriend(new UUID((string)requestData["ownerID"]),
267 new UUID((string) requestData["friendID"]));
268 returnString = "TRUE";
269 }
270 responseData["returnString"] = returnString;
271 response.Value = responseData;
272 return response;
273 }
274
275 public XmlRpcResponse XmlRpcResponseXmlRPCUpdateUserFriendPerms(XmlRpcRequest request)
276 {
277 XmlRpcResponse response = new XmlRpcResponse();
278 Hashtable requestData = (Hashtable) request.Params[0];
279 Hashtable responseData = new Hashtable();
280 string returnString = "FALSE";
281
282 if (requestData.Contains("ownerID") && requestData.Contains("friendID") &&
283 requestData.Contains("friendPerms"))
284 {
285 m_userDataBaseService.UpdateUserFriendPerms(new UUID((string)requestData["ownerID"]),
286 new UUID((string) requestData["friendID"]),
287 (uint) Convert.ToInt32((string) requestData["friendPerms"]));
288 // UserManagerBase.
289 returnString = "TRUE";
290 }
291 responseData["returnString"] = returnString;
292 response.Value = responseData;
293 return response;
294 }
295
296 public XmlRpcResponse XmlRpcResponseXmlRPCGetUserFriendList(XmlRpcRequest request)
297 {
298 // XmlRpcResponse response = new XmlRpcResponse();
299 Hashtable requestData = (Hashtable) request.Params[0];
300 // Hashtable responseData = new Hashtable();
301
302 List<FriendListItem> returndata = new List<FriendListItem>();
303
304 if (requestData.Contains("ownerID"))
305 {
306 returndata = m_userDataBaseService.GetUserFriendList(new UUID((string)requestData["ownerID"]));
307 }
308
309 return FriendListItemListtoXmlRPCResponse(returndata);
310 }
311
312 public XmlRpcResponse XmlRPCGetAvatarAppearance(XmlRpcRequest request)
313 {
314 XmlRpcResponse response = new XmlRpcResponse();
315 Hashtable requestData = (Hashtable) request.Params[0];
316 AvatarAppearance appearance;
317 Hashtable responseData;
318 if (requestData.Contains("owner"))
319 {
320 appearance = m_userDataBaseService.GetUserAppearance(new UUID((string)requestData["owner"]));
321 if (appearance == null)
322 {
323 responseData = new Hashtable();
324 responseData["error_type"] = "no appearance";
325 responseData["error_desc"] = "There was no appearance found for this avatar";
326 }
327 else
328 {
329 responseData = appearance.ToHashTable();
330 }
331 }
332 else
333 {
334 responseData = new Hashtable();
335 responseData["error_type"] = "unknown_avatar";
336 responseData["error_desc"] = "The avatar appearance requested is not in the database";
337 }
338
339 response.Value = responseData;
340 return response;
341 }
342
343 public XmlRpcResponse XmlRPCUpdateAvatarAppearance(XmlRpcRequest request)
344 {
345 XmlRpcResponse response = new XmlRpcResponse();
346 Hashtable requestData = (Hashtable) request.Params[0];
347 Hashtable responseData;
348 if (requestData.Contains("owner"))
349 {
350 AvatarAppearance appearance = new AvatarAppearance(requestData);
351 m_userDataBaseService.UpdateUserAppearance(new UUID((string)requestData["owner"]), appearance);
352 responseData = new Hashtable();
353 responseData["returnString"] = "TRUE";
354 }
355 else
356 {
357 responseData = new Hashtable();
358 responseData["error_type"] = "unknown_avatar";
359 responseData["error_desc"] = "The avatar appearance requested is not in the database";
360 }
361 response.Value = responseData;
362 return response;
363 }
364
365 public XmlRpcResponse XmlRPCGetUserMethodName(XmlRpcRequest request) 242 public XmlRpcResponse XmlRPCGetUserMethodName(XmlRpcRequest request)
366 { 243 {
367 // XmlRpcResponse response = new XmlRpcResponse(); 244 // XmlRpcResponse response = new XmlRpcResponse();
diff --git a/OpenSim/Grid/UserServer/UserServerAvatarAppearanceModule.cs b/OpenSim/Grid/UserServer/UserServerAvatarAppearanceModule.cs
new file mode 100644
index 0000000..28ac2dc
--- /dev/null
+++ b/OpenSim/Grid/UserServer/UserServerAvatarAppearanceModule.cs
@@ -0,0 +1,124 @@
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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Reflection;
32using log4net;
33using Nwc.XmlRpc;
34using OpenMetaverse;
35using OpenSim.Framework;
36using OpenSim.Framework.Communications;
37using OpenSim.Framework.Servers;
38
39namespace OpenSim.Grid.UserServer
40{
41 public class UserServerAvatarAppearanceModule
42 {
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44
45 private UserDataBaseService m_userDataBaseService;
46 private BaseHttpServer m_httpServer;
47
48 public UserServerAvatarAppearanceModule(UserDataBaseService userDataBaseService)
49 {
50 m_userDataBaseService = userDataBaseService;
51 }
52
53 public void Initialise()
54 {
55
56 }
57
58 public void PostInitialise()
59 {
60
61 }
62
63 public void RegisterHandlers(BaseHttpServer httpServer)
64 {
65 m_httpServer = httpServer;
66
67 m_httpServer.AddXmlRPCHandler("get_avatar_appearance", XmlRPCGetAvatarAppearance);
68 m_httpServer.AddXmlRPCHandler("update_avatar_appearance", XmlRPCUpdateAvatarAppearance);
69 }
70
71 public XmlRpcResponse XmlRPCGetAvatarAppearance(XmlRpcRequest request)
72 {
73 XmlRpcResponse response = new XmlRpcResponse();
74 Hashtable requestData = (Hashtable)request.Params[0];
75 AvatarAppearance appearance;
76 Hashtable responseData;
77 if (requestData.Contains("owner"))
78 {
79 appearance = m_userDataBaseService.GetUserAppearance(new UUID((string)requestData["owner"]));
80 if (appearance == null)
81 {
82 responseData = new Hashtable();
83 responseData["error_type"] = "no appearance";
84 responseData["error_desc"] = "There was no appearance found for this avatar";
85 }
86 else
87 {
88 responseData = appearance.ToHashTable();
89 }
90 }
91 else
92 {
93 responseData = new Hashtable();
94 responseData["error_type"] = "unknown_avatar";
95 responseData["error_desc"] = "The avatar appearance requested is not in the database";
96 }
97
98 response.Value = responseData;
99 return response;
100 }
101
102 public XmlRpcResponse XmlRPCUpdateAvatarAppearance(XmlRpcRequest request)
103 {
104 XmlRpcResponse response = new XmlRpcResponse();
105 Hashtable requestData = (Hashtable)request.Params[0];
106 Hashtable responseData;
107 if (requestData.Contains("owner"))
108 {
109 AvatarAppearance appearance = new AvatarAppearance(requestData);
110 m_userDataBaseService.UpdateUserAppearance(new UUID((string)requestData["owner"]), appearance);
111 responseData = new Hashtable();
112 responseData["returnString"] = "TRUE";
113 }
114 else
115 {
116 responseData = new Hashtable();
117 responseData["error_type"] = "unknown_avatar";
118 responseData["error_desc"] = "The avatar appearance requested is not in the database";
119 }
120 response.Value = responseData;
121 return response;
122 }
123 }
124}
diff --git a/OpenSim/Grid/UserServer/UserServerFriendsModule.cs b/OpenSim/Grid/UserServer/UserServerFriendsModule.cs
new file mode 100644
index 0000000..4a3efe0
--- /dev/null
+++ b/OpenSim/Grid/UserServer/UserServerFriendsModule.cs
@@ -0,0 +1,173 @@
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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Reflection;
32using log4net;
33using Nwc.XmlRpc;
34using OpenMetaverse;
35using OpenSim.Framework;
36using OpenSim.Framework.Communications;
37using OpenSim.Framework.Servers;
38
39namespace OpenSim.Grid.UserServer
40{
41 public class UserServerFriendsModule
42 {
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44
45 private UserDataBaseService m_userDataBaseService;
46
47 private BaseHttpServer m_httpServer;
48
49 public UserServerFriendsModule(UserDataBaseService userDataBaseService)
50 {
51 m_userDataBaseService = userDataBaseService;
52 }
53
54 public void Initialise()
55 {
56
57 }
58
59 public void PostInitialise()
60 {
61
62 }
63
64 public void RegisterHandlers(BaseHttpServer httpServer)
65 {
66 m_httpServer = httpServer;
67
68 m_httpServer.AddXmlRPCHandler("add_new_user_friend", XmlRpcResponseXmlRPCAddUserFriend);
69 m_httpServer.AddXmlRPCHandler("remove_user_friend", XmlRpcResponseXmlRPCRemoveUserFriend);
70 m_httpServer.AddXmlRPCHandler("update_user_friend_perms", XmlRpcResponseXmlRPCUpdateUserFriendPerms);
71 m_httpServer.AddXmlRPCHandler("get_user_friend_list", XmlRpcResponseXmlRPCGetUserFriendList);
72 }
73
74 public XmlRpcResponse FriendListItemListtoXmlRPCResponse(List<FriendListItem> returnUsers)
75 {
76 XmlRpcResponse response = new XmlRpcResponse();
77 Hashtable responseData = new Hashtable();
78 // Query Result Information
79
80 responseData["avcount"] = returnUsers.Count.ToString();
81
82 for (int i = 0; i < returnUsers.Count; i++)
83 {
84 responseData["ownerID" + i] = returnUsers[i].FriendListOwner.ToString();
85 responseData["friendID" + i] = returnUsers[i].Friend.ToString();
86 responseData["ownerPerms" + i] = returnUsers[i].FriendListOwnerPerms.ToString();
87 responseData["friendPerms" + i] = returnUsers[i].FriendPerms.ToString();
88 }
89 response.Value = responseData;
90
91 return response;
92 }
93
94 public XmlRpcResponse XmlRpcResponseXmlRPCAddUserFriend(XmlRpcRequest request)
95 {
96 XmlRpcResponse response = new XmlRpcResponse();
97 Hashtable requestData = (Hashtable)request.Params[0];
98 Hashtable responseData = new Hashtable();
99 string returnString = "FALSE";
100 // Query Result Information
101
102 if (requestData.Contains("ownerID") && requestData.Contains("friendID") &&
103 requestData.Contains("friendPerms"))
104 {
105 // UserManagerBase.AddNewuserFriend
106 m_userDataBaseService.AddNewUserFriend(new UUID((string)requestData["ownerID"]),
107 new UUID((string)requestData["friendID"]),
108 (uint)Convert.ToInt32((string)requestData["friendPerms"]));
109 returnString = "TRUE";
110 }
111 responseData["returnString"] = returnString;
112 response.Value = responseData;
113 return response;
114 }
115
116 public XmlRpcResponse XmlRpcResponseXmlRPCRemoveUserFriend(XmlRpcRequest request)
117 {
118 XmlRpcResponse response = new XmlRpcResponse();
119 Hashtable requestData = (Hashtable)request.Params[0];
120 Hashtable responseData = new Hashtable();
121 string returnString = "FALSE";
122 // Query Result Information
123
124 if (requestData.Contains("ownerID") && requestData.Contains("friendID"))
125 {
126 // UserManagerBase.AddNewuserFriend
127 m_userDataBaseService.RemoveUserFriend(new UUID((string)requestData["ownerID"]),
128 new UUID((string)requestData["friendID"]));
129 returnString = "TRUE";
130 }
131 responseData["returnString"] = returnString;
132 response.Value = responseData;
133 return response;
134 }
135
136 public XmlRpcResponse XmlRpcResponseXmlRPCUpdateUserFriendPerms(XmlRpcRequest request)
137 {
138 XmlRpcResponse response = new XmlRpcResponse();
139 Hashtable requestData = (Hashtable)request.Params[0];
140 Hashtable responseData = new Hashtable();
141 string returnString = "FALSE";
142
143 if (requestData.Contains("ownerID") && requestData.Contains("friendID") &&
144 requestData.Contains("friendPerms"))
145 {
146 m_userDataBaseService.UpdateUserFriendPerms(new UUID((string)requestData["ownerID"]),
147 new UUID((string)requestData["friendID"]),
148 (uint)Convert.ToInt32((string)requestData["friendPerms"]));
149 // UserManagerBase.
150 returnString = "TRUE";
151 }
152 responseData["returnString"] = returnString;
153 response.Value = responseData;
154 return response;
155 }
156
157 public XmlRpcResponse XmlRpcResponseXmlRPCGetUserFriendList(XmlRpcRequest request)
158 {
159 // XmlRpcResponse response = new XmlRpcResponse();
160 Hashtable requestData = (Hashtable)request.Params[0];
161 // Hashtable responseData = new Hashtable();
162
163 List<FriendListItem> returndata = new List<FriendListItem>();
164
165 if (requestData.Contains("ownerID"))
166 {
167 returndata = m_userDataBaseService.GetUserFriendList(new UUID((string)requestData["ownerID"]));
168 }
169
170 return FriendListItemListtoXmlRPCResponse(returndata);
171 }
172 }
173}