aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications/Cache/UserProfileCache.cs
diff options
context:
space:
mode:
authorMW2007-07-25 18:19:38 +0000
committerMW2007-07-25 18:19:38 +0000
commit2b42ea0a429c722bd7c5c67d3815c2ddc8399e78 (patch)
tree0a6338ff52efbdaadaa9a307bee618867460cfb6 /OpenSim/Framework/Communications/Cache/UserProfileCache.cs
parent* Terrain now uses the older slower method again until the fast version can b... (diff)
downloadopensim-SC-2b42ea0a429c722bd7c5c67d3815c2ddc8399e78.zip
opensim-SC-2b42ea0a429c722bd7c5c67d3815c2ddc8399e78.tar.gz
opensim-SC-2b42ea0a429c722bd7c5c67d3815c2ddc8399e78.tar.bz2
opensim-SC-2b42ea0a429c722bd7c5c67d3815c2ddc8399e78.tar.xz
Start of the OpenSim library , for now only contains a few textures.
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Communications/Cache/UserProfileCache.cs386
1 files changed, 216 insertions, 170 deletions
diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs
index 8210702..7b4f6a5 100644
--- a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs
+++ b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs
@@ -1,170 +1,216 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Text; 31using System.Text;
32using System.IO; 32using System.IO;
33using libsecondlife; 33using libsecondlife;
34using OpenSim.Framework.Interfaces; 34using OpenSim.Framework.Interfaces;
35using OpenSim.Framework.Types; 35using OpenSim.Framework.Types;
36using OpenSim.Framework.Utilities; 36using OpenSim.Framework.Utilities;
37using OpenSim.Framework.Data; 37using OpenSim.Framework.Data;
38 38
39namespace OpenSim.Framework.Communications.Caches 39namespace OpenSim.Framework.Communications.Caches
40{ 40{
41 41 public class UserProfileCache
42 public class UserProfileCache 42 {
43 { 43 // Fields
44 // Fields 44 private CommunicationsManager m_parent;
45 private CommunicationsManager m_parent; 45 public Dictionary<LLUUID, CachedUserInfo> UserProfiles = new Dictionary<LLUUID, CachedUserInfo>();
46 public Dictionary<LLUUID, CachedUserInfo> UserProfiles = new Dictionary<LLUUID, CachedUserInfo>(); 46
47 47 public LibraryRootFolder libraryRoot = new LibraryRootFolder();
48 // Methods 48
49 public UserProfileCache(CommunicationsManager parent) 49 // Methods
50 { 50 public UserProfileCache(CommunicationsManager parent)
51 this.m_parent = parent; 51 {
52 } 52 this.m_parent = parent;
53 53 }
54 public void AddNewUser(LLUUID userID) 54
55 { 55 /// <summary>
56 if (!this.UserProfiles.ContainsKey(userID)) 56 /// A new user has moved into a region in this instance
57 { 57 /// so get info from servers
58 CachedUserInfo userInfo = new CachedUserInfo(); 58 /// </summary>
59 userInfo.UserProfile = this.RequestUserProfileForUser(userID); 59 /// <param name="userID"></param>
60 if (userInfo.UserProfile != null) 60 public void AddNewUser(LLUUID userID)
61 { 61 {
62 this.RequestInventoryForUser(userID, userInfo); 62 if (!this.UserProfiles.ContainsKey(userID))
63 this.UserProfiles.Add(userID, userInfo); 63 {
64 } 64 CachedUserInfo userInfo = new CachedUserInfo();
65 else 65 userInfo.UserProfile = this.RequestUserProfileForUser(userID);
66 { 66 if (userInfo.UserProfile != null)
67 Console.WriteLine("UserProfileCache.cs: user profile for user not found"); 67 {
68 } 68 this.RequestInventoryForUser(userID, userInfo);
69 } 69 this.UserProfiles.Add(userID, userInfo);
70 } 70 }
71 71 else
72 public void AddNewUser(string firstName, string lastName) 72 {
73 { 73 Console.WriteLine("UserProfileCache.cs: user profile for user not found");
74 } 74 }
75 75 }
76 public CachedUserInfo GetUserDetails(LLUUID userID) 76 }
77 { 77
78 if (this.UserProfiles.ContainsKey(userID)) 78 /// <summary>
79 { 79 /// A new user has moved into a region in this instance
80 return this.UserProfiles[userID]; 80 /// so get info from servers
81 } 81 /// </summary>
82 return null; 82 /// <param name="firstName"></param>
83 } 83 /// <param name="lastName"></param>
84 84 public void AddNewUser(string firstName, string lastName)
85 public void HandleCreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType, string folderName, LLUUID parentID) 85 {
86 { 86 }
87 if (this.UserProfiles.ContainsKey(remoteClient.AgentId)) 87
88 { 88 public CachedUserInfo GetUserDetails(LLUUID userID)
89 CachedUserInfo info = this.UserProfiles[remoteClient.AgentId]; 89 {
90 if (info.RootFolder.folderID == parentID) 90 if (this.UserProfiles.ContainsKey(userID))
91 { 91 {
92 info.RootFolder.CreateNewSubFolder(folderID, folderName, folderType); 92 return this.UserProfiles[userID];
93 } 93 }
94 else 94 return null;
95 { 95 }
96 InventoryFolder folder = info.RootFolder.HasSubFolder(parentID); 96
97 if (folder != null) 97 public void HandleCreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType, string folderName, LLUUID parentID)
98 { 98 {
99 folder.CreateNewSubFolder(folderID, folderName, folderType); 99 if (this.UserProfiles.ContainsKey(remoteClient.AgentId))
100 } 100 {
101 } 101 CachedUserInfo info = this.UserProfiles[remoteClient.AgentId];
102 } 102 if (info.RootFolder.folderID == parentID)
103 } 103 {
104 104 info.RootFolder.CreateNewSubFolder(folderID, folderName, folderType);
105 public void HandleFecthInventoryDescendents(IClientAPI remoteClient, LLUUID folderID, LLUUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) 105 }
106 { 106 else
107 if (this.UserProfiles.ContainsKey(remoteClient.AgentId)) 107 {
108 { 108 InventoryFolder folder = info.RootFolder.HasSubFolder(parentID);
109 CachedUserInfo info = this.UserProfiles[remoteClient.AgentId]; 109 if (folder != null)
110 if (info.RootFolder.folderID == folderID) 110 {
111 { 111 folder.CreateNewSubFolder(folderID, folderName, folderType);
112 if (fetchItems) 112 }
113 { 113 }
114 remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, info.RootFolder.RequestListOfItems()); 114 }
115 } 115 }
116 } 116
117 else 117 public void HandleFecthInventoryDescendents(IClientAPI remoteClient, LLUUID folderID, LLUUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder)
118 { 118 {
119 InventoryFolder folder = info.RootFolder.HasSubFolder(folderID); 119 if (folderID == libraryRoot.folderID )
120 if ((folder != null) && fetchItems) 120 {
121 { 121 remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, libraryRoot.folderID, libraryRoot.RequestListOfItems());
122 remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, folder.RequestListOfItems()); 122 }
123 } 123 else if (this.UserProfiles.ContainsKey(remoteClient.AgentId))
124 } 124 {
125 } 125 CachedUserInfo info = this.UserProfiles[remoteClient.AgentId];
126 } 126 if (info.RootFolder.folderID == folderID)
127 127 {
128 public void HandleFetchInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID ownerID) 128 if (fetchItems)
129 { 129 {
130 if (this.UserProfiles.ContainsKey(remoteClient.AgentId)) 130 remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, info.RootFolder.RequestListOfItems());
131 { 131 }
132 InventoryItemBase item = this.UserProfiles[remoteClient.AgentId].RootFolder.HasItem(itemID); 132 }
133 if (item != null) 133 else
134 { 134 {
135 remoteClient.SendInventoryItemDetails(ownerID, item); 135 InventoryFolder folder = info.RootFolder.HasSubFolder(folderID);
136 } 136 if ((folder != null) && fetchItems)
137 } 137 {
138 } 138 remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, folder.RequestListOfItems());
139 139 }
140 private void RequestInventoryForUser(LLUUID userID, CachedUserInfo userInfo) 140 }
141 { 141 }
142 InventoryFolder folderInfo = new InventoryFolder(); 142 }
143 folderInfo.agentID = userID; 143
144 folderInfo.folderID = userInfo.UserProfile.rootInventoryFolderID; 144 public void HandleFetchInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID ownerID)
145 folderInfo.name = "My Inventory"; 145 {
146 folderInfo.parentID = LLUUID.Zero; 146 if (ownerID == libraryRoot.agentID)
147 folderInfo.type = 8; 147 {
148 folderInfo.version = 1; 148 //Console.WriteLine("request info for library item");
149 userInfo.FolderReceive(userID, folderInfo); 149 }
150 } 150 else if (this.UserProfiles.ContainsKey(remoteClient.AgentId))
151 151 {
152 private UserProfileData RequestUserProfileForUser(LLUUID userID) 152 InventoryItemBase item = this.UserProfiles[remoteClient.AgentId].RootFolder.HasItem(itemID);
153 { 153 if (item != null)
154 return this.m_parent.UserServer.GetUserProfile(userID); 154 {
155 } 155 remoteClient.SendInventoryItemDetails(ownerID, item);
156 156 }
157 private void UpdateInventoryToServer(LLUUID userID) 157 }
158 { 158 }
159 } 159
160 160 /// <summary>
161 private void UpdateUserProfileToServer(LLUUID userID) 161 /// Request Iventory Info from Inventory server
162 { 162 /// </summary>
163 } 163 /// <param name="userID"></param>
164 164 private void RequestInventoryForUser(LLUUID userID, CachedUserInfo userInfo)
165 public void UserLogOut(LLUUID userID) 165 {
166 { 166 // this.m_parent.InventoryServer.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive);
167 } 167
168 } 168 //for now we manually create the root folder,
169} 169 // but should be requesting all inventory from inventory server.
170 170 InventoryFolder folderInfo = new InventoryFolder();
171 folderInfo.agentID = userID;
172 folderInfo.folderID = userInfo.UserProfile.rootInventoryFolderID;
173 folderInfo.name = "My Inventory";
174 folderInfo.parentID = LLUUID.Zero;
175 folderInfo.type = 8;
176 folderInfo.version = 1;
177 userInfo.FolderReceive(userID, folderInfo);
178 }
179
180 /// <summary>
181 /// Request the user profile from User server
182 /// </summary>
183 /// <param name="userID"></param>
184 private UserProfileData RequestUserProfileForUser(LLUUID userID)
185 {
186 return this.m_parent.UserServer.GetUserProfile(userID);
187 }
188
189 /// <summary>
190 /// Update Inventory data to Inventory server
191 /// </summary>
192 /// <param name="userID"></param>
193 private void UpdateInventoryToServer(LLUUID userID)
194 {
195 }
196
197 /// <summary>
198 /// Make sure UserProfile is updated on user server
199 /// </summary>
200 /// <param name="userID"></param>
201 private void UpdateUserProfileToServer(LLUUID userID)
202 {
203 }
204
205 /// <summary>
206 /// A user has left this instance
207 /// so make sure servers have been updated
208 /// Then remove cached info
209 /// </summary>
210 /// <param name="userID"></param>
211 public void UserLogOut(LLUUID userID)
212 {
213 }
214 }
215}
216