aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/UserServer/UserServerFriendsModule.cs
diff options
context:
space:
mode:
authorMW2009-02-24 13:33:57 +0000
committerMW2009-02-24 13:33:57 +0000
commit2a91f21d082aee4dc97b5b0d29e1739cfe409024 (patch)
tree950cf659d45ffc05367814c0075b48f4a2aabbc5 /OpenSim/Grid/UserServer/UserServerFriendsModule.cs
parentupdate version number for bamboo zip file output (diff)
downloadopensim-SC_OLD-2a91f21d082aee4dc97b5b0d29e1739cfe409024.zip
opensim-SC_OLD-2a91f21d082aee4dc97b5b0d29e1739cfe409024.tar.gz
opensim-SC_OLD-2a91f21d082aee4dc97b5b0d29e1739cfe409024.tar.bz2
opensim-SC_OLD-2a91f21d082aee4dc97b5b0d29e1739cfe409024.tar.xz
More refactoring of the UserServer.
Diffstat (limited to '')
-rw-r--r--OpenSim/Grid/UserServer/UserServerFriendsModule.cs173
1 files changed, 173 insertions, 0 deletions
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}