diff options
Diffstat (limited to 'OpenSim/Framework/Communications/CommunicationsManager.cs')
-rw-r--r-- | OpenSim/Framework/Communications/CommunicationsManager.cs | 264 |
1 files changed, 0 insertions, 264 deletions
diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs deleted file mode 100644 index 4bf9018..0000000 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ /dev/null | |||
@@ -1,264 +0,0 @@ | |||
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.Collections.Generic; | ||
30 | using OpenMetaverse; | ||
31 | using OpenSim.Framework.Communications.Cache; | ||
32 | |||
33 | namespace OpenSim.Framework.Communications | ||
34 | { | ||
35 | /// <summary> | ||
36 | /// This class manages references to OpenSim non-region services (inventory, user, etc.) | ||
37 | /// </summary> | ||
38 | /// | ||
39 | /// TODO: Service retrieval needs to be managed via plugin and interfaces requests, as happens for region | ||
40 | /// modules from scene. Among other things, this will allow this class to be used in many different contexts | ||
41 | /// (from a grid service executable, to provide services on a region) without lots of messy nulls and confusion. | ||
42 | /// Also, a post initialize step on the plugins will be needed so that we don't get tortuous problems with | ||
43 | /// circular dependencies between plugins. | ||
44 | public class CommunicationsManager | ||
45 | { | ||
46 | //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
48 | protected Dictionary<UUID, string[]> m_nameRequestCache = new Dictionary<UUID, string[]>(); | ||
49 | |||
50 | public IUserService UserService | ||
51 | { | ||
52 | get { return m_userService; } | ||
53 | } | ||
54 | protected IUserService m_userService; | ||
55 | |||
56 | public IMessagingService MessageService | ||
57 | { | ||
58 | get { return m_messageService; } | ||
59 | } | ||
60 | protected IMessagingService m_messageService; | ||
61 | |||
62 | |||
63 | public UserProfileCacheService UserProfileCacheService | ||
64 | { | ||
65 | get { return m_userProfileCacheService; } | ||
66 | } | ||
67 | protected UserProfileCacheService m_userProfileCacheService; | ||
68 | |||
69 | public IAvatarService AvatarService | ||
70 | { | ||
71 | get { return m_avatarService; } | ||
72 | } | ||
73 | protected IAvatarService m_avatarService; | ||
74 | |||
75 | public IInterServiceInventoryServices InterServiceInventoryService | ||
76 | { | ||
77 | get { return m_interServiceInventoryService; } | ||
78 | } | ||
79 | protected IInterServiceInventoryServices m_interServiceInventoryService; | ||
80 | |||
81 | public NetworkServersInfo NetworkServersInfo | ||
82 | { | ||
83 | get { return m_networkServersInfo; } | ||
84 | } | ||
85 | protected NetworkServersInfo m_networkServersInfo; | ||
86 | |||
87 | /// <summary> | ||
88 | /// Interface to user service for administrating users. | ||
89 | /// </summary> | ||
90 | public IUserAdminService UserAdminService | ||
91 | { | ||
92 | get { return m_userAdminService; } | ||
93 | } | ||
94 | protected IUserAdminService m_userAdminService; | ||
95 | |||
96 | /// <summary> | ||
97 | /// Constructor | ||
98 | /// </summary> | ||
99 | /// <param name="serversInfo"></param> | ||
100 | public CommunicationsManager(NetworkServersInfo serversInfo, | ||
101 | LibraryRootFolder libraryRootFolder) | ||
102 | { | ||
103 | m_networkServersInfo = serversInfo; | ||
104 | m_userProfileCacheService = new UserProfileCacheService(this, libraryRootFolder); | ||
105 | } | ||
106 | |||
107 | |||
108 | #region Friend Methods | ||
109 | |||
110 | /// <summary> | ||
111 | /// Adds a new friend to the database for XUser | ||
112 | /// </summary> | ||
113 | /// <param name="friendlistowner">The agent that who's friends list is being added to</param> | ||
114 | /// <param name="friend">The agent that being added to the friends list of the friends list owner</param> | ||
115 | /// <param name="perms">A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects </param> | ||
116 | public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) | ||
117 | { | ||
118 | m_userService.AddNewUserFriend(friendlistowner, friend, perms); | ||
119 | } | ||
120 | |||
121 | /// <summary> | ||
122 | /// Logs off a user and does the appropriate communications | ||
123 | /// </summary> | ||
124 | /// <param name="userid"></param> | ||
125 | /// <param name="regionid"></param> | ||
126 | /// <param name="regionhandle"></param> | ||
127 | /// <param name="position"></param> | ||
128 | /// <param name="lookat"></param> | ||
129 | public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat) | ||
130 | { | ||
131 | m_userService.LogOffUser(userid, regionid, regionhandle, position, lookat); | ||
132 | } | ||
133 | |||
134 | /// <summary> | ||
135 | /// Logs off a user and does the appropriate communications (deprecated as of 2008-08-27) | ||
136 | /// </summary> | ||
137 | /// <param name="userid"></param> | ||
138 | /// <param name="regionid"></param> | ||
139 | /// <param name="regionhandle"></param> | ||
140 | /// <param name="posx"></param> | ||
141 | /// <param name="posy"></param> | ||
142 | /// <param name="posz"></param> | ||
143 | public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz) | ||
144 | { | ||
145 | m_userService.LogOffUser(userid, regionid, regionhandle, posx, posy, posz); | ||
146 | } | ||
147 | |||
148 | /// <summary> | ||
149 | /// Delete friend on friendlistowner's friendlist. | ||
150 | /// </summary> | ||
151 | /// <param name="friendlistowner">The agent that who's friends list is being updated</param> | ||
152 | /// <param name="friend">The Ex-friend agent</param> | ||
153 | public void RemoveUserFriend(UUID friendlistowner, UUID friend) | ||
154 | { | ||
155 | m_userService.RemoveUserFriend(friendlistowner, friend); | ||
156 | } | ||
157 | |||
158 | /// <summary> | ||
159 | /// Update permissions for friend on friendlistowner's friendlist. | ||
160 | /// </summary> | ||
161 | /// <param name="friendlistowner">The agent that who's friends list is being updated</param> | ||
162 | /// <param name="friend">The agent that is getting or loosing permissions</param> | ||
163 | /// <param name="perms">A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects </param> | ||
164 | public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) | ||
165 | { | ||
166 | m_userService.UpdateUserFriendPerms(friendlistowner, friend, perms); | ||
167 | } | ||
168 | |||
169 | /// <summary> | ||
170 | /// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship for UUID friendslistowner | ||
171 | /// </summary> | ||
172 | /// <param name="friendlistowner">The agent that we're retreiving the friends Data.</param> | ||
173 | public List<FriendListItem> GetUserFriendList(UUID friendlistowner) | ||
174 | { | ||
175 | return m_userService.GetUserFriendList(friendlistowner); | ||
176 | } | ||
177 | |||
178 | public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos(List<UUID> uuids) | ||
179 | { | ||
180 | return m_messageService.GetFriendRegionInfos(uuids); | ||
181 | } | ||
182 | |||
183 | #endregion | ||
184 | |||
185 | #region Packet Handlers | ||
186 | |||
187 | public void UpdateAvatarPropertiesRequest(IClientAPI remote_client, UserProfileData UserProfile) | ||
188 | { | ||
189 | m_userService.UpdateUserProfile(UserProfile); | ||
190 | return; | ||
191 | } | ||
192 | |||
193 | public void HandleUUIDNameRequest(UUID uuid, IClientAPI remote_client) | ||
194 | { | ||
195 | if (uuid == m_userProfileCacheService.LibraryRoot.Owner) | ||
196 | { | ||
197 | remote_client.SendNameReply(uuid, "Mr", "OpenSim"); | ||
198 | } | ||
199 | else | ||
200 | { | ||
201 | string[] names = doUUIDNameRequest(uuid); | ||
202 | if (names.Length == 2) | ||
203 | { | ||
204 | remote_client.SendNameReply(uuid, names[0], names[1]); | ||
205 | } | ||
206 | |||
207 | } | ||
208 | } | ||
209 | |||
210 | private string[] doUUIDNameRequest(UUID uuid) | ||
211 | { | ||
212 | lock (m_nameRequestCache) | ||
213 | { | ||
214 | if (m_nameRequestCache.ContainsKey(uuid)) | ||
215 | return m_nameRequestCache[uuid]; | ||
216 | } | ||
217 | |||
218 | string[] returnstring = new string[0]; | ||
219 | CachedUserInfo uinfo = UserProfileCacheService.GetUserDetails(uuid); | ||
220 | |||
221 | if ((uinfo != null) && (uinfo.UserProfile != null)) | ||
222 | { | ||
223 | returnstring = new string[2]; | ||
224 | returnstring[0] = uinfo.UserProfile.FirstName; | ||
225 | returnstring[1] = uinfo.UserProfile.SurName; | ||
226 | lock (m_nameRequestCache) | ||
227 | { | ||
228 | if (!m_nameRequestCache.ContainsKey(uuid)) | ||
229 | m_nameRequestCache.Add(uuid, returnstring); | ||
230 | } | ||
231 | } | ||
232 | |||
233 | return returnstring; | ||
234 | } | ||
235 | |||
236 | public bool UUIDNameCachedTest(UUID uuid) | ||
237 | { | ||
238 | lock (m_nameRequestCache) | ||
239 | return m_nameRequestCache.ContainsKey(uuid); | ||
240 | } | ||
241 | |||
242 | public string UUIDNameRequestString(UUID uuid) | ||
243 | { | ||
244 | string[] names = doUUIDNameRequest(uuid); | ||
245 | if (names.Length == 2) | ||
246 | { | ||
247 | string firstname = names[0]; | ||
248 | string lastname = names[1]; | ||
249 | |||
250 | return firstname + " " + lastname; | ||
251 | |||
252 | } | ||
253 | return "(hippos)"; | ||
254 | } | ||
255 | |||
256 | public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query) | ||
257 | { | ||
258 | List<AvatarPickerAvatar> pickerlist = m_userService.GenerateAgentPickerRequestResponse(queryID, query); | ||
259 | return pickerlist; | ||
260 | } | ||
261 | |||
262 | #endregion | ||
263 | } | ||
264 | } | ||