aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications/Cache/UserProfileCache.cs
diff options
context:
space:
mode:
authorMW2007-07-22 13:31:08 +0000
committerMW2007-07-22 13:31:08 +0000
commit276011a0a149c5ea81dd106137889c840c10b738 (patch)
tree69145783615e0fde4f4e927fba603b8ebdc321b4 /OpenSim/Framework/Communications/Cache/UserProfileCache.cs
parent* Some work in progress code: Inventory cache, start of inventory server/serv... (diff)
downloadopensim-SC_OLD-276011a0a149c5ea81dd106137889c840c10b738.zip
opensim-SC_OLD-276011a0a149c5ea81dd106137889c840c10b738.tar.gz
opensim-SC_OLD-276011a0a149c5ea81dd106137889c840c10b738.tar.bz2
opensim-SC_OLD-276011a0a149c5ea81dd106137889c840c10b738.tar.xz
Think I've recovered my deleted files, so hopefully it works now.
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Communications/Cache/UserProfileCache.cs170
1 files changed, 170 insertions, 0 deletions
diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs
new file mode 100644
index 0000000..8210702
--- /dev/null
+++ b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs
@@ -0,0 +1,170 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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.Text;
32using System.IO;
33using libsecondlife;
34using OpenSim.Framework.Interfaces;
35using OpenSim.Framework.Types;
36using OpenSim.Framework.Utilities;
37using OpenSim.Framework.Data;
38
39namespace OpenSim.Framework.Communications.Caches
40{
41
42 public class UserProfileCache
43 {
44 // Fields
45 private CommunicationsManager m_parent;
46 public Dictionary<LLUUID, CachedUserInfo> UserProfiles = new Dictionary<LLUUID, CachedUserInfo>();
47
48 // Methods
49 public UserProfileCache(CommunicationsManager parent)
50 {
51 this.m_parent = parent;
52 }
53
54 public void AddNewUser(LLUUID userID)
55 {
56 if (!this.UserProfiles.ContainsKey(userID))
57 {
58 CachedUserInfo userInfo = new CachedUserInfo();
59 userInfo.UserProfile = this.RequestUserProfileForUser(userID);
60 if (userInfo.UserProfile != null)
61 {
62 this.RequestInventoryForUser(userID, userInfo);
63 this.UserProfiles.Add(userID, userInfo);
64 }
65 else
66 {
67 Console.WriteLine("UserProfileCache.cs: user profile for user not found");
68 }
69 }
70 }
71
72 public void AddNewUser(string firstName, string lastName)
73 {
74 }
75
76 public CachedUserInfo GetUserDetails(LLUUID userID)
77 {
78 if (this.UserProfiles.ContainsKey(userID))
79 {
80 return this.UserProfiles[userID];
81 }
82 return null;
83 }
84
85 public void HandleCreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType, string folderName, LLUUID parentID)
86 {
87 if (this.UserProfiles.ContainsKey(remoteClient.AgentId))
88 {
89 CachedUserInfo info = this.UserProfiles[remoteClient.AgentId];
90 if (info.RootFolder.folderID == parentID)
91 {
92 info.RootFolder.CreateNewSubFolder(folderID, folderName, folderType);
93 }
94 else
95 {
96 InventoryFolder folder = info.RootFolder.HasSubFolder(parentID);
97 if (folder != null)
98 {
99 folder.CreateNewSubFolder(folderID, folderName, folderType);
100 }
101 }
102 }
103 }
104
105 public void HandleFecthInventoryDescendents(IClientAPI remoteClient, LLUUID folderID, LLUUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder)
106 {
107 if (this.UserProfiles.ContainsKey(remoteClient.AgentId))
108 {
109 CachedUserInfo info = this.UserProfiles[remoteClient.AgentId];
110 if (info.RootFolder.folderID == folderID)
111 {
112 if (fetchItems)
113 {
114 remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, info.RootFolder.RequestListOfItems());
115 }
116 }
117 else
118 {
119 InventoryFolder folder = info.RootFolder.HasSubFolder(folderID);
120 if ((folder != null) && fetchItems)
121 {
122 remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, folder.RequestListOfItems());
123 }
124 }
125 }
126 }
127
128 public void HandleFetchInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID ownerID)
129 {
130 if (this.UserProfiles.ContainsKey(remoteClient.AgentId))
131 {
132 InventoryItemBase item = this.UserProfiles[remoteClient.AgentId].RootFolder.HasItem(itemID);
133 if (item != null)
134 {
135 remoteClient.SendInventoryItemDetails(ownerID, item);
136 }
137 }
138 }
139
140 private void RequestInventoryForUser(LLUUID userID, CachedUserInfo userInfo)
141 {
142 InventoryFolder folderInfo = new InventoryFolder();
143 folderInfo.agentID = userID;
144 folderInfo.folderID = userInfo.UserProfile.rootInventoryFolderID;
145 folderInfo.name = "My Inventory";
146 folderInfo.parentID = LLUUID.Zero;
147 folderInfo.type = 8;
148 folderInfo.version = 1;
149 userInfo.FolderReceive(userID, folderInfo);
150 }
151
152 private UserProfileData RequestUserProfileForUser(LLUUID userID)
153 {
154 return this.m_parent.UserServer.GetUserProfile(userID);
155 }
156
157 private void UpdateInventoryToServer(LLUUID userID)
158 {
159 }
160
161 private void UpdateUserProfileToServer(LLUUID userID)
162 {
163 }
164
165 public void UserLogOut(LLUUID userID)
166 {
167 }
168 }
169}
170