diff options
author | Justin Clark-Casey (justincc) | 2009-09-18 19:26:22 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2009-09-18 19:26:22 +0100 |
commit | a1e688bdf3ab354104545623bb1784213d479e0a (patch) | |
tree | d29552ec2f6cb3d3136cdab68e36a9969285e88d /OpenSim/Grid | |
parent | Remove old OpenSim.Example.xml file that doesn't keep up with OpenSim.ini.exa... (diff) | |
parent | addition of a new script function osSetParcelSIPAddress(string SIPAddress), n... (diff) | |
download | opensim-SC_OLD-a1e688bdf3ab354104545623bb1784213d479e0a.zip opensim-SC_OLD-a1e688bdf3ab354104545623bb1784213d479e0a.tar.gz opensim-SC_OLD-a1e688bdf3ab354104545623bb1784213d479e0a.tar.bz2 opensim-SC_OLD-a1e688bdf3ab354104545623bb1784213d479e0a.tar.xz |
Merge branch 'master' of ssh://justincc@opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Grid')
-rw-r--r-- | OpenSim/Grid/AssetServer/Main.cs | 146 | ||||
-rw-r--r-- | OpenSim/Grid/AssetServer/Properties/AssemblyInfo.cs | 63 | ||||
-rw-r--r-- | OpenSim/Grid/InventoryServer/AuthedSessionCache.cs | 133 | ||||
-rw-r--r-- | OpenSim/Grid/InventoryServer/GridInventoryService.cs | 256 | ||||
-rw-r--r-- | OpenSim/Grid/InventoryServer/InventoryServiceBase.cs | 519 | ||||
-rw-r--r-- | OpenSim/Grid/InventoryServer/Main.cs | 182 |
6 files changed, 0 insertions, 1299 deletions
diff --git a/OpenSim/Grid/AssetServer/Main.cs b/OpenSim/Grid/AssetServer/Main.cs deleted file mode 100644 index ac8f888..0000000 --- a/OpenSim/Grid/AssetServer/Main.cs +++ /dev/null | |||
@@ -1,146 +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.IO; | ||
30 | using System.Reflection; | ||
31 | using log4net; | ||
32 | using log4net.Config; | ||
33 | using OpenMetaverse; | ||
34 | using OpenSim.Data; | ||
35 | using OpenSim.Framework; | ||
36 | using OpenSim.Framework.AssetLoader.Filesystem; | ||
37 | using OpenSim.Framework.Console; | ||
38 | using OpenSim.Framework.Servers; | ||
39 | using OpenSim.Framework.Servers.HttpServer; | ||
40 | using OpenSim.Framework.Statistics; | ||
41 | |||
42 | namespace OpenSim.Grid.AssetServer | ||
43 | { | ||
44 | /// <summary> | ||
45 | /// An asset server | ||
46 | /// </summary> | ||
47 | public class OpenAsset_Main : BaseOpenSimServer | ||
48 | { | ||
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
50 | |||
51 | public static OpenAsset_Main assetserver; | ||
52 | |||
53 | // Temporarily hardcoded - should be a plugin | ||
54 | protected IAssetLoader assetLoader = new AssetLoaderFileSystem(); | ||
55 | |||
56 | private IAssetDataPlugin m_assetProvider; | ||
57 | |||
58 | public static void Main(string[] args) | ||
59 | { | ||
60 | XmlConfigurator.Configure(); | ||
61 | |||
62 | assetserver = new OpenAsset_Main(); | ||
63 | assetserver.Startup(); | ||
64 | |||
65 | assetserver.Work(); | ||
66 | } | ||
67 | |||
68 | private void Work() | ||
69 | { | ||
70 | m_console.Output("Enter help for a list of commands"); | ||
71 | |||
72 | while (true) | ||
73 | { | ||
74 | m_console.Prompt(); | ||
75 | } | ||
76 | } | ||
77 | |||
78 | public OpenAsset_Main() | ||
79 | { | ||
80 | m_console = new LocalConsole("Asset"); | ||
81 | |||
82 | MainConsole.Instance = m_console; | ||
83 | } | ||
84 | |||
85 | protected override void StartupSpecific() | ||
86 | { | ||
87 | AssetConfig config = new AssetConfig("ASSET SERVER", (Path.Combine(Util.configDir(), "AssetServer_Config.xml"))); | ||
88 | |||
89 | m_log.Info("[ASSET]: Setting up asset DB"); | ||
90 | setupDB(config); | ||
91 | |||
92 | m_log.Info("[ASSET]: Loading default asset set from '" + config.AssetSetsLocation + "'"); | ||
93 | LoadDefaultAssets(config.AssetSetsLocation); | ||
94 | |||
95 | m_log.Info("[ASSET]: Starting HTTP process"); | ||
96 | m_httpServer = new BaseHttpServer(config.HttpPort); | ||
97 | |||
98 | m_stats = StatsManager.StartCollectingAssetStats(); | ||
99 | |||
100 | AddHttpHandlers(); | ||
101 | |||
102 | m_httpServer.Start(); | ||
103 | |||
104 | base.StartupSpecific(); | ||
105 | } | ||
106 | |||
107 | protected void AddHttpHandlers() | ||
108 | { | ||
109 | m_httpServer.AddStreamHandler(new GetAssetStreamHandler(m_assetProvider)); | ||
110 | m_httpServer.AddStreamHandler(new PostAssetStreamHandler(m_assetProvider)); | ||
111 | } | ||
112 | |||
113 | public byte[] GetAssetData(UUID assetID, bool isTexture) | ||
114 | { | ||
115 | return null; | ||
116 | } | ||
117 | |||
118 | public void setupDB(AssetConfig config) | ||
119 | { | ||
120 | try | ||
121 | { | ||
122 | m_assetProvider = DataPluginFactory.LoadDataPlugin<IAssetDataPlugin>(config.DatabaseProvider, config.DatabaseConnect); | ||
123 | if (m_assetProvider == null) | ||
124 | { | ||
125 | m_log.Error("[ASSET]: Failed to load a database plugin, server halting"); | ||
126 | Environment.Exit(-1); | ||
127 | } | ||
128 | } | ||
129 | catch (Exception e) | ||
130 | { | ||
131 | m_log.Warn("[ASSET]: setupDB() - Exception occured"); | ||
132 | m_log.Warn("[ASSET]: " + e.ToString()); | ||
133 | } | ||
134 | } | ||
135 | |||
136 | public void LoadDefaultAssets(string pAssetSetsLocation) | ||
137 | { | ||
138 | assetLoader.ForEachDefaultXmlAsset(pAssetSetsLocation, StoreAsset); | ||
139 | } | ||
140 | |||
141 | protected void StoreAsset(AssetBase asset) | ||
142 | { | ||
143 | m_assetProvider.StoreAsset(asset); | ||
144 | } | ||
145 | } | ||
146 | } | ||
diff --git a/OpenSim/Grid/AssetServer/Properties/AssemblyInfo.cs b/OpenSim/Grid/AssetServer/Properties/AssemblyInfo.cs deleted file mode 100644 index 5d67e3f..0000000 --- a/OpenSim/Grid/AssetServer/Properties/AssemblyInfo.cs +++ /dev/null | |||
@@ -1,63 +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.Reflection; | ||
29 | using System.Runtime.InteropServices; | ||
30 | |||
31 | // General information about an assembly is controlled through the following | ||
32 | // set of attributes. Change these attribute values to modify the information | ||
33 | // associated with an assembly. | ||
34 | |||
35 | [assembly : AssemblyTitle("OGS-AssetServer")] | ||
36 | [assembly : AssemblyDescription("")] | ||
37 | [assembly : AssemblyConfiguration("")] | ||
38 | [assembly : AssemblyCompany("http://opensimulator.org")] | ||
39 | [assembly : AssemblyProduct("OGS-AssetServer")] | ||
40 | [assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2009")] | ||
41 | [assembly : AssemblyTrademark("")] | ||
42 | [assembly : AssemblyCulture("")] | ||
43 | |||
44 | // Setting ComVisible to false makes the types in this assembly not visible | ||
45 | // to COM components. If you need to access a type in this assembly from | ||
46 | // COM, set the ComVisible attribute to true on that type. | ||
47 | |||
48 | [assembly : ComVisible(false)] | ||
49 | |||
50 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
51 | |||
52 | [assembly : Guid("b541b244-3d1d-4625-9003-bc2a3a6a39a4")] | ||
53 | |||
54 | // Version information for an assembly consists of the following four values: | ||
55 | // | ||
56 | // Major Version | ||
57 | // Minor Version | ||
58 | // Build Number | ||
59 | // Revision | ||
60 | // | ||
61 | |||
62 | [assembly : AssemblyVersion("0.6.5.*")] | ||
63 | [assembly : AssemblyFileVersion("0.6.5.0")] | ||
diff --git a/OpenSim/Grid/InventoryServer/AuthedSessionCache.cs b/OpenSim/Grid/InventoryServer/AuthedSessionCache.cs deleted file mode 100644 index dadf34a..0000000 --- a/OpenSim/Grid/InventoryServer/AuthedSessionCache.cs +++ /dev/null | |||
@@ -1,133 +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 | |||
31 | namespace OpenSim.Grid.InventoryServer | ||
32 | { | ||
33 | public class AuthedSessionCache | ||
34 | { | ||
35 | public class CacheData | ||
36 | { | ||
37 | private static readonly DateTime UNIX_EPOCH = new DateTime(1970, 1, 1); | ||
38 | private string m_session_id; | ||
39 | private string m_agent_id; | ||
40 | private int m_expire; | ||
41 | |||
42 | private int get_current_unix_time() | ||
43 | { | ||
44 | return (int)(DateTime.UtcNow - UNIX_EPOCH).TotalSeconds; | ||
45 | } | ||
46 | |||
47 | public CacheData(string sid, string aid) | ||
48 | { | ||
49 | m_session_id = sid; | ||
50 | m_agent_id = aid; | ||
51 | m_expire = get_current_unix_time() + DEFAULT_LIFETIME; | ||
52 | } | ||
53 | |||
54 | public CacheData(string sid, string aid, int time_now) | ||
55 | { | ||
56 | m_session_id = sid; | ||
57 | m_agent_id = aid; | ||
58 | m_expire = time_now + DEFAULT_LIFETIME; | ||
59 | } | ||
60 | |||
61 | public string SessionID | ||
62 | { | ||
63 | get { return m_session_id; } | ||
64 | set { m_session_id = value; } | ||
65 | } | ||
66 | |||
67 | public string AgentID | ||
68 | { | ||
69 | get { return m_agent_id; } | ||
70 | set { m_agent_id = value; } | ||
71 | } | ||
72 | |||
73 | public bool isExpired | ||
74 | { | ||
75 | get { return m_expire < get_current_unix_time(); } | ||
76 | } | ||
77 | |||
78 | public void Renew() | ||
79 | { | ||
80 | m_expire = get_current_unix_time() + DEFAULT_LIFETIME; | ||
81 | } | ||
82 | } | ||
83 | |||
84 | private static readonly int DEFAULT_LIFETIME = 30; | ||
85 | private Dictionary<string, CacheData> m_authed_sessions = new Dictionary<string,CacheData>(); | ||
86 | // private int m_session_lifetime = DEFAULT_LIFETIME; | ||
87 | |||
88 | public AuthedSessionCache() | ||
89 | { | ||
90 | // m_session_lifetime = DEFAULT_LIFETIME; | ||
91 | } | ||
92 | |||
93 | public AuthedSessionCache(int timeout) | ||
94 | { | ||
95 | // m_session_lifetime = timeout; | ||
96 | } | ||
97 | |||
98 | public CacheData getCachedSession(string session_id, string agent_id) | ||
99 | { | ||
100 | CacheData ret = null; | ||
101 | lock (m_authed_sessions) | ||
102 | { | ||
103 | if (m_authed_sessions.ContainsKey(session_id)) | ||
104 | { | ||
105 | CacheData cached_session = m_authed_sessions[session_id]; | ||
106 | if (!cached_session.isExpired && cached_session.AgentID == agent_id) | ||
107 | { | ||
108 | ret = m_authed_sessions[session_id]; | ||
109 | // auto renew | ||
110 | m_authed_sessions[session_id].Renew(); | ||
111 | } | ||
112 | } | ||
113 | } | ||
114 | return ret; | ||
115 | } | ||
116 | |||
117 | public void Add(string session_id, string agent_id) | ||
118 | { | ||
119 | CacheData data = new CacheData(session_id, agent_id); | ||
120 | lock (m_authed_sessions) | ||
121 | { | ||
122 | if (m_authed_sessions.ContainsKey(session_id)) | ||
123 | { | ||
124 | m_authed_sessions[session_id] = data; | ||
125 | } | ||
126 | else | ||
127 | { | ||
128 | m_authed_sessions.Add(session_id, data); | ||
129 | } | ||
130 | } | ||
131 | } | ||
132 | } | ||
133 | } | ||
diff --git a/OpenSim/Grid/InventoryServer/GridInventoryService.cs b/OpenSim/Grid/InventoryServer/GridInventoryService.cs deleted file mode 100644 index 0704faa..0000000 --- a/OpenSim/Grid/InventoryServer/GridInventoryService.cs +++ /dev/null | |||
@@ -1,256 +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; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | using log4net; | ||
34 | using Nwc.XmlRpc; | ||
35 | using OpenMetaverse; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Framework.Communications; | ||
38 | using OpenSim.Framework.Communications.Cache; | ||
39 | |||
40 | namespace OpenSim.Grid.InventoryServer | ||
41 | { | ||
42 | /// <summary> | ||
43 | /// Used on a grid server to satisfy external inventory requests | ||
44 | /// </summary> | ||
45 | public class GridInventoryService : InventoryServiceBase | ||
46 | { | ||
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
48 | |||
49 | private bool m_doLookup = false; | ||
50 | |||
51 | public bool DoLookup | ||
52 | { | ||
53 | get { return m_doLookup; } | ||
54 | set { m_doLookup = value; } | ||
55 | } | ||
56 | |||
57 | private static readonly int INVENTORY_DEFAULT_SESSION_TIME = 30; // secs | ||
58 | |||
59 | private string m_userserver_url; | ||
60 | private AuthedSessionCache m_session_cache = new AuthedSessionCache(INVENTORY_DEFAULT_SESSION_TIME); | ||
61 | |||
62 | public GridInventoryService(string userserver_url) | ||
63 | { | ||
64 | m_userserver_url = userserver_url; | ||
65 | } | ||
66 | |||
67 | /// <summary> | ||
68 | /// Check that the source of an inventory request is one that we trust. | ||
69 | /// </summary> | ||
70 | /// <param name="peer"></param> | ||
71 | /// <returns></returns> | ||
72 | public bool CheckTrustSource(IPEndPoint peer) | ||
73 | { | ||
74 | if (m_doLookup) | ||
75 | { | ||
76 | m_log.InfoFormat("[GRID AGENT INVENTORY]: Checking trusted source {0}", peer); | ||
77 | UriBuilder ub = new UriBuilder(m_userserver_url); | ||
78 | IPAddress[] uaddrs = Dns.GetHostAddresses(ub.Host); | ||
79 | foreach (IPAddress uaddr in uaddrs) | ||
80 | { | ||
81 | if (uaddr.Equals(peer.Address)) | ||
82 | { | ||
83 | return true; | ||
84 | } | ||
85 | } | ||
86 | |||
87 | m_log.WarnFormat( | ||
88 | "[GRID AGENT INVENTORY]: Rejecting request since source {0} was not in the list of trusted sources", | ||
89 | peer); | ||
90 | |||
91 | return false; | ||
92 | } | ||
93 | else | ||
94 | { | ||
95 | return true; | ||
96 | } | ||
97 | } | ||
98 | |||
99 | /// <summary> | ||
100 | /// Check that the source of an inventory request for a particular agent is a current session belonging to | ||
101 | /// that agent. | ||
102 | /// </summary> | ||
103 | /// <param name="session_id"></param> | ||
104 | /// <param name="avatar_id"></param> | ||
105 | /// <returns></returns> | ||
106 | public bool CheckAuthSession(string session_id, string avatar_id) | ||
107 | { | ||
108 | if (m_doLookup) | ||
109 | { | ||
110 | m_log.InfoFormat("[GRID AGENT INVENTORY]: checking authed session {0} {1}", session_id, avatar_id); | ||
111 | |||
112 | if (m_session_cache.getCachedSession(session_id, avatar_id) == null) | ||
113 | { | ||
114 | // cache miss, ask userserver | ||
115 | Hashtable requestData = new Hashtable(); | ||
116 | requestData["avatar_uuid"] = avatar_id; | ||
117 | requestData["session_id"] = session_id; | ||
118 | ArrayList SendParams = new ArrayList(); | ||
119 | SendParams.Add(requestData); | ||
120 | XmlRpcRequest UserReq = new XmlRpcRequest("check_auth_session", SendParams); | ||
121 | XmlRpcResponse UserResp = UserReq.Send(m_userserver_url, 3000); | ||
122 | |||
123 | Hashtable responseData = (Hashtable)UserResp.Value; | ||
124 | if (responseData.ContainsKey("auth_session") && responseData["auth_session"].ToString() == "TRUE") | ||
125 | { | ||
126 | m_log.Info("[GRID AGENT INVENTORY]: got authed session from userserver"); | ||
127 | // add to cache; the session time will be automatically renewed | ||
128 | m_session_cache.Add(session_id, avatar_id); | ||
129 | return true; | ||
130 | } | ||
131 | } | ||
132 | else | ||
133 | { | ||
134 | // cache hits | ||
135 | m_log.Info("[GRID AGENT INVENTORY]: got authed session from cache"); | ||
136 | return true; | ||
137 | } | ||
138 | |||
139 | m_log.Warn("[GRID AGENT INVENTORY]: unknown session_id, request rejected"); | ||
140 | return false; | ||
141 | } | ||
142 | else | ||
143 | { | ||
144 | return true; | ||
145 | } | ||
146 | } | ||
147 | |||
148 | /// <summary> | ||
149 | /// Return a user's entire inventory | ||
150 | /// </summary> | ||
151 | /// <param name="rawUserID"></param> | ||
152 | /// <returns>The user's inventory. If an inventory cannot be found then an empty collection is returned.</returns> | ||
153 | public InventoryCollection GetUserInventory(Guid rawUserID) | ||
154 | { | ||
155 | UUID userID = new UUID(rawUserID); | ||
156 | |||
157 | m_log.InfoFormat("[GRID AGENT INVENTORY]: Processing request for inventory of {0}", userID); | ||
158 | |||
159 | // Uncomment me to simulate a slow responding inventory server | ||
160 | //Thread.Sleep(16000); | ||
161 | |||
162 | InventoryCollection invCollection = new InventoryCollection(); | ||
163 | |||
164 | List<InventoryFolderBase> allFolders = GetInventorySkeleton(userID); | ||
165 | |||
166 | if (null == allFolders) | ||
167 | { | ||
168 | m_log.WarnFormat("[GRID AGENT INVENTORY]: No inventory found for user {0}", rawUserID); | ||
169 | |||
170 | return invCollection; | ||
171 | } | ||
172 | |||
173 | List<InventoryItemBase> allItems = new List<InventoryItemBase>(); | ||
174 | |||
175 | foreach (InventoryFolderBase folder in allFolders) | ||
176 | { | ||
177 | List<InventoryItemBase> items = RequestFolderItems(folder.ID); | ||
178 | |||
179 | if (items != null) | ||
180 | { | ||
181 | allItems.InsertRange(0, items); | ||
182 | } | ||
183 | } | ||
184 | |||
185 | invCollection.UserID = userID; | ||
186 | invCollection.Folders = allFolders; | ||
187 | invCollection.Items = allItems; | ||
188 | |||
189 | // foreach (InventoryFolderBase folder in invCollection.Folders) | ||
190 | // { | ||
191 | // m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back folder {0} {1}", folder.Name, folder.ID); | ||
192 | // } | ||
193 | // | ||
194 | // foreach (InventoryItemBase item in invCollection.Items) | ||
195 | // { | ||
196 | // m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back item {0} {1}, folder {2}", item.Name, item.ID, item.Folder); | ||
197 | // } | ||
198 | |||
199 | m_log.InfoFormat( | ||
200 | "[GRID AGENT INVENTORY]: Sending back inventory response to user {0} containing {1} folders and {2} items", | ||
201 | invCollection.UserID, invCollection.Folders.Count, invCollection.Items.Count); | ||
202 | |||
203 | return invCollection; | ||
204 | } | ||
205 | |||
206 | public List<InventoryItemBase> GetFolderItems(Guid folderID) | ||
207 | { | ||
208 | List<InventoryItemBase> allItems = new List<InventoryItemBase>(); | ||
209 | |||
210 | |||
211 | List<InventoryItemBase> items = RequestFolderItems(new UUID(folderID)); | ||
212 | |||
213 | if (items != null) | ||
214 | { | ||
215 | allItems.InsertRange(0, items); | ||
216 | } | ||
217 | m_log.InfoFormat( | ||
218 | "[GRID AGENT INVENTORY]: Sending back inventory response containing {0} items", allItems.Count.ToString()); | ||
219 | return allItems; | ||
220 | } | ||
221 | |||
222 | /// <summary> | ||
223 | /// Guid to UUID wrapper for same name IInventoryServices method | ||
224 | /// </summary> | ||
225 | /// <param name="rawUserID"></param> | ||
226 | /// <returns></returns> | ||
227 | public List<InventoryFolderBase> GetInventorySkeleton(Guid rawUserID) | ||
228 | { | ||
229 | UUID userID = new UUID(rawUserID); | ||
230 | return GetInventorySkeleton(userID); | ||
231 | } | ||
232 | |||
233 | /// <summary> | ||
234 | /// Create an inventory for the given user. | ||
235 | /// </summary> | ||
236 | /// <param name="rawUserID"></param> | ||
237 | /// <returns></returns> | ||
238 | public bool CreateUsersInventory(Guid rawUserID) | ||
239 | { | ||
240 | UUID userID = new UUID(rawUserID); | ||
241 | |||
242 | m_log.InfoFormat("[GRID AGENT INVENTORY]: Creating new set of inventory folders for user {0}", userID); | ||
243 | |||
244 | return CreateNewUserInventory(userID); | ||
245 | } | ||
246 | |||
247 | public List<InventoryItemBase> GetActiveGestures(Guid rawUserID) | ||
248 | { | ||
249 | UUID userID = new UUID(rawUserID); | ||
250 | |||
251 | m_log.InfoFormat("[GRID AGENT INVENTORY]: fetching active gestures for user {0}", userID); | ||
252 | |||
253 | return GetActiveGestures(userID); | ||
254 | } | ||
255 | } | ||
256 | } | ||
diff --git a/OpenSim/Grid/InventoryServer/InventoryServiceBase.cs b/OpenSim/Grid/InventoryServer/InventoryServiceBase.cs deleted file mode 100644 index f8b4949..0000000 --- a/OpenSim/Grid/InventoryServer/InventoryServiceBase.cs +++ /dev/null | |||
@@ -1,519 +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.Collections.Generic; | ||
29 | using System.Reflection; | ||
30 | using log4net; | ||
31 | using OpenMetaverse; | ||
32 | using OpenSim.Data; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Framework.Communications; | ||
35 | |||
36 | namespace OpenSim.Grid.InventoryServer | ||
37 | { | ||
38 | /// <summary> | ||
39 | /// Abstract base class used by local and grid implementations of an inventory service. | ||
40 | /// </summary> | ||
41 | public abstract class InventoryServiceBase : IInterServiceInventoryServices | ||
42 | { | ||
43 | |||
44 | private static readonly ILog m_log | ||
45 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
46 | |||
47 | protected List<IInventoryDataPlugin> m_plugins = new List<IInventoryDataPlugin>(); | ||
48 | |||
49 | #region Plugin methods | ||
50 | |||
51 | /// <summary> | ||
52 | /// Add a new inventory data plugin - plugins will be requested in the order they were added. | ||
53 | /// </summary> | ||
54 | /// <param name="plugin">The plugin that will provide data</param> | ||
55 | public void AddPlugin(IInventoryDataPlugin plugin) | ||
56 | { | ||
57 | m_plugins.Add(plugin); | ||
58 | } | ||
59 | |||
60 | /// <summary> | ||
61 | /// Adds a list of inventory data plugins, as described by `provider' | ||
62 | /// and `connect', to `m_plugins'. | ||
63 | /// </summary> | ||
64 | /// <param name="provider"> | ||
65 | /// The filename of the inventory server plugin DLL. | ||
66 | /// </param> | ||
67 | /// <param name="connect"> | ||
68 | /// The connection string for the storage backend. | ||
69 | /// </param> | ||
70 | public void AddPlugin(string provider, string connect) | ||
71 | { | ||
72 | m_plugins.AddRange(DataPluginFactory.LoadDataPlugins<IInventoryDataPlugin>(provider, connect)); | ||
73 | } | ||
74 | |||
75 | #endregion | ||
76 | |||
77 | #region IInventoryServices methods | ||
78 | |||
79 | public string Host | ||
80 | { | ||
81 | get { return "default"; } | ||
82 | } | ||
83 | |||
84 | public List<InventoryFolderBase> GetInventorySkeleton(UUID userId) | ||
85 | { | ||
86 | // m_log.DebugFormat("[AGENT INVENTORY]: Getting inventory skeleton for {0}", userId); | ||
87 | |||
88 | InventoryFolderBase rootFolder = RequestRootFolder(userId); | ||
89 | |||
90 | // Agent has no inventory structure yet. | ||
91 | if (null == rootFolder) | ||
92 | { | ||
93 | return null; | ||
94 | } | ||
95 | |||
96 | List<InventoryFolderBase> userFolders = new List<InventoryFolderBase>(); | ||
97 | |||
98 | userFolders.Add(rootFolder); | ||
99 | |||
100 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
101 | { | ||
102 | IList<InventoryFolderBase> folders = plugin.getFolderHierarchy(rootFolder.ID); | ||
103 | userFolders.AddRange(folders); | ||
104 | } | ||
105 | |||
106 | // foreach (InventoryFolderBase folder in userFolders) | ||
107 | // { | ||
108 | // m_log.DebugFormat("[AGENT INVENTORY]: Got folder {0} {1}", folder.name, folder.folderID); | ||
109 | // } | ||
110 | |||
111 | return userFolders; | ||
112 | } | ||
113 | |||
114 | // See IInventoryServices | ||
115 | public virtual bool HasInventoryForUser(UUID userID) | ||
116 | { | ||
117 | return false; | ||
118 | } | ||
119 | |||
120 | // See IInventoryServices | ||
121 | public virtual InventoryFolderBase RequestRootFolder(UUID userID) | ||
122 | { | ||
123 | // Retrieve the first root folder we get from the list of plugins. | ||
124 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
125 | { | ||
126 | InventoryFolderBase rootFolder = plugin.getUserRootFolder(userID); | ||
127 | if (rootFolder != null) | ||
128 | return rootFolder; | ||
129 | } | ||
130 | |||
131 | // Return nothing if no plugin was able to supply a root folder | ||
132 | return null; | ||
133 | } | ||
134 | |||
135 | // See IInventoryServices | ||
136 | public bool CreateNewUserInventory(UUID user) | ||
137 | { | ||
138 | InventoryFolderBase existingRootFolder = RequestRootFolder(user); | ||
139 | |||
140 | if (null != existingRootFolder) | ||
141 | { | ||
142 | m_log.WarnFormat( | ||
143 | "[AGENT INVENTORY]: Did not create a new inventory for user {0} since they already have " | ||
144 | + "a root inventory folder with id {1}", | ||
145 | user, existingRootFolder.ID); | ||
146 | } | ||
147 | else | ||
148 | { | ||
149 | UsersInventory inven = new UsersInventory(); | ||
150 | inven.CreateNewInventorySet(user); | ||
151 | AddNewInventorySet(inven); | ||
152 | |||
153 | return true; | ||
154 | } | ||
155 | |||
156 | return false; | ||
157 | } | ||
158 | |||
159 | public List<InventoryItemBase> GetActiveGestures(UUID userId) | ||
160 | { | ||
161 | List<InventoryItemBase> activeGestures = new List<InventoryItemBase>(); | ||
162 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
163 | { | ||
164 | activeGestures.AddRange(plugin.fetchActiveGestures(userId)); | ||
165 | } | ||
166 | |||
167 | return activeGestures; | ||
168 | } | ||
169 | |||
170 | #endregion | ||
171 | |||
172 | #region Methods used by GridInventoryService | ||
173 | |||
174 | public List<InventoryFolderBase> RequestSubFolders(UUID parentFolderID) | ||
175 | { | ||
176 | List<InventoryFolderBase> inventoryList = new List<InventoryFolderBase>(); | ||
177 | |||
178 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
179 | { | ||
180 | inventoryList.AddRange(plugin.getInventoryFolders(parentFolderID)); | ||
181 | } | ||
182 | |||
183 | return inventoryList; | ||
184 | } | ||
185 | |||
186 | public List<InventoryItemBase> RequestFolderItems(UUID folderID) | ||
187 | { | ||
188 | List<InventoryItemBase> itemsList = new List<InventoryItemBase>(); | ||
189 | |||
190 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
191 | { | ||
192 | itemsList.AddRange(plugin.getInventoryInFolder(folderID)); | ||
193 | } | ||
194 | |||
195 | return itemsList; | ||
196 | } | ||
197 | |||
198 | #endregion | ||
199 | |||
200 | // See IInventoryServices | ||
201 | public virtual bool AddFolder(InventoryFolderBase folder) | ||
202 | { | ||
203 | m_log.DebugFormat( | ||
204 | "[AGENT INVENTORY]: Adding folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); | ||
205 | |||
206 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
207 | { | ||
208 | plugin.addInventoryFolder(folder); | ||
209 | } | ||
210 | |||
211 | // FIXME: Should return false on failure | ||
212 | return true; | ||
213 | } | ||
214 | |||
215 | // See IInventoryServices | ||
216 | public virtual bool UpdateFolder(InventoryFolderBase folder) | ||
217 | { | ||
218 | m_log.DebugFormat( | ||
219 | "[AGENT INVENTORY]: Updating folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); | ||
220 | |||
221 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
222 | { | ||
223 | plugin.updateInventoryFolder(folder); | ||
224 | } | ||
225 | |||
226 | // FIXME: Should return false on failure | ||
227 | return true; | ||
228 | } | ||
229 | |||
230 | // See IInventoryServices | ||
231 | public virtual bool MoveFolder(InventoryFolderBase folder) | ||
232 | { | ||
233 | m_log.DebugFormat( | ||
234 | "[AGENT INVENTORY]: Moving folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); | ||
235 | |||
236 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
237 | { | ||
238 | plugin.moveInventoryFolder(folder); | ||
239 | } | ||
240 | |||
241 | // FIXME: Should return false on failure | ||
242 | return true; | ||
243 | } | ||
244 | |||
245 | // See IInventoryServices | ||
246 | public virtual bool AddItem(InventoryItemBase item) | ||
247 | { | ||
248 | m_log.DebugFormat( | ||
249 | "[AGENT INVENTORY]: Adding item {0} {1} to folder {2}", item.Name, item.ID, item.Folder); | ||
250 | |||
251 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
252 | { | ||
253 | plugin.addInventoryItem(item); | ||
254 | } | ||
255 | |||
256 | // FIXME: Should return false on failure | ||
257 | return true; | ||
258 | } | ||
259 | |||
260 | // See IInventoryServices | ||
261 | public virtual bool UpdateItem(InventoryItemBase item) | ||
262 | { | ||
263 | m_log.InfoFormat( | ||
264 | "[AGENT INVENTORY]: Updating item {0} {1} in folder {2}", item.Name, item.ID, item.Folder); | ||
265 | |||
266 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
267 | { | ||
268 | plugin.updateInventoryItem(item); | ||
269 | } | ||
270 | |||
271 | // FIXME: Should return false on failure | ||
272 | return true; | ||
273 | } | ||
274 | |||
275 | // See IInventoryServices | ||
276 | public virtual bool DeleteItem(InventoryItemBase item) | ||
277 | { | ||
278 | m_log.InfoFormat( | ||
279 | "[AGENT INVENTORY]: Deleting item {0} {1} from folder {2}", item.Name, item.ID, item.Folder); | ||
280 | |||
281 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
282 | { | ||
283 | plugin.deleteInventoryItem(item.ID); | ||
284 | } | ||
285 | |||
286 | // FIXME: Should return false on failure | ||
287 | return true; | ||
288 | } | ||
289 | |||
290 | public virtual InventoryItemBase QueryItem(InventoryItemBase item) | ||
291 | { | ||
292 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
293 | { | ||
294 | InventoryItemBase result = plugin.queryInventoryItem(item.ID); | ||
295 | if (result != null) | ||
296 | return result; | ||
297 | } | ||
298 | |||
299 | return null; | ||
300 | } | ||
301 | |||
302 | public virtual InventoryFolderBase QueryFolder(InventoryFolderBase item) | ||
303 | { | ||
304 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
305 | { | ||
306 | InventoryFolderBase result = plugin.queryInventoryFolder(item.ID); | ||
307 | if (result != null) | ||
308 | return result; | ||
309 | } | ||
310 | |||
311 | return null; | ||
312 | } | ||
313 | |||
314 | /// <summary> | ||
315 | /// Purge a folder of all items items and subfolders. | ||
316 | /// | ||
317 | /// FIXME: Really nasty in a sense, because we have to query the database to get information we may | ||
318 | /// already know... Needs heavy refactoring. | ||
319 | /// </summary> | ||
320 | /// <param name="folder"></param> | ||
321 | public virtual bool PurgeFolder(InventoryFolderBase folder) | ||
322 | { | ||
323 | m_log.DebugFormat( | ||
324 | "[AGENT INVENTORY]: Purging folder {0} {1} of its contents", folder.Name, folder.ID); | ||
325 | |||
326 | List<InventoryFolderBase> subFolders = RequestSubFolders(folder.ID); | ||
327 | |||
328 | foreach (InventoryFolderBase subFolder in subFolders) | ||
329 | { | ||
330 | // m_log.DebugFormat("[AGENT INVENTORY]: Deleting folder {0} {1}", subFolder.Name, subFolder.ID); | ||
331 | |||
332 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
333 | { | ||
334 | plugin.deleteInventoryFolder(subFolder.ID); | ||
335 | } | ||
336 | } | ||
337 | |||
338 | List<InventoryItemBase> items = RequestFolderItems(folder.ID); | ||
339 | |||
340 | foreach (InventoryItemBase item in items) | ||
341 | { | ||
342 | DeleteItem(item); | ||
343 | } | ||
344 | |||
345 | // FIXME: Should return false on failure | ||
346 | return true; | ||
347 | } | ||
348 | |||
349 | private void AddNewInventorySet(UsersInventory inventory) | ||
350 | { | ||
351 | foreach (InventoryFolderBase folder in inventory.Folders.Values) | ||
352 | { | ||
353 | AddFolder(folder); | ||
354 | } | ||
355 | } | ||
356 | |||
357 | public InventoryItemBase GetInventoryItem(UUID itemID) | ||
358 | { | ||
359 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
360 | { | ||
361 | InventoryItemBase item = plugin.getInventoryItem(itemID); | ||
362 | if (item != null) | ||
363 | return item; | ||
364 | } | ||
365 | |||
366 | return null; | ||
367 | } | ||
368 | |||
369 | /// <summary> | ||
370 | /// Used to create a new user inventory. | ||
371 | /// </summary> | ||
372 | private class UsersInventory | ||
373 | { | ||
374 | public Dictionary<UUID, InventoryFolderBase> Folders = new Dictionary<UUID, InventoryFolderBase>(); | ||
375 | public Dictionary<UUID, InventoryItemBase> Items = new Dictionary<UUID, InventoryItemBase>(); | ||
376 | |||
377 | public virtual void CreateNewInventorySet(UUID user) | ||
378 | { | ||
379 | InventoryFolderBase folder = new InventoryFolderBase(); | ||
380 | |||
381 | folder.ParentID = UUID.Zero; | ||
382 | folder.Owner = user; | ||
383 | folder.ID = UUID.Random(); | ||
384 | folder.Name = "My Inventory"; | ||
385 | folder.Type = (short)AssetType.Folder; | ||
386 | folder.Version = 1; | ||
387 | Folders.Add(folder.ID, folder); | ||
388 | |||
389 | UUID rootFolder = folder.ID; | ||
390 | |||
391 | folder = new InventoryFolderBase(); | ||
392 | folder.ParentID = rootFolder; | ||
393 | folder.Owner = user; | ||
394 | folder.ID = UUID.Random(); | ||
395 | folder.Name = "Animations"; | ||
396 | folder.Type = (short)AssetType.Animation; | ||
397 | folder.Version = 1; | ||
398 | Folders.Add(folder.ID, folder); | ||
399 | |||
400 | folder = new InventoryFolderBase(); | ||
401 | folder.ParentID = rootFolder; | ||
402 | folder.Owner = user; | ||
403 | folder.ID = UUID.Random(); | ||
404 | folder.Name = "Body Parts"; | ||
405 | folder.Type = (short)AssetType.Bodypart; | ||
406 | folder.Version = 1; | ||
407 | Folders.Add(folder.ID, folder); | ||
408 | |||
409 | folder = new InventoryFolderBase(); | ||
410 | folder.ParentID = rootFolder; | ||
411 | folder.Owner = user; | ||
412 | folder.ID = UUID.Random(); | ||
413 | folder.Name = "Calling Cards"; | ||
414 | folder.Type = (short)AssetType.CallingCard; | ||
415 | folder.Version = 1; | ||
416 | Folders.Add(folder.ID, folder); | ||
417 | |||
418 | folder = new InventoryFolderBase(); | ||
419 | folder.ParentID = rootFolder; | ||
420 | folder.Owner = user; | ||
421 | folder.ID = UUID.Random(); | ||
422 | folder.Name = "Clothing"; | ||
423 | folder.Type = (short)AssetType.Clothing; | ||
424 | folder.Version = 1; | ||
425 | Folders.Add(folder.ID, folder); | ||
426 | |||
427 | folder = new InventoryFolderBase(); | ||
428 | folder.ParentID = rootFolder; | ||
429 | folder.Owner = user; | ||
430 | folder.ID = UUID.Random(); | ||
431 | folder.Name = "Gestures"; | ||
432 | folder.Type = (short)AssetType.Gesture; | ||
433 | folder.Version = 1; | ||
434 | Folders.Add(folder.ID, folder); | ||
435 | |||
436 | folder = new InventoryFolderBase(); | ||
437 | folder.ParentID = rootFolder; | ||
438 | folder.Owner = user; | ||
439 | folder.ID = UUID.Random(); | ||
440 | folder.Name = "Landmarks"; | ||
441 | folder.Type = (short)AssetType.Landmark; | ||
442 | folder.Version = 1; | ||
443 | Folders.Add(folder.ID, folder); | ||
444 | |||
445 | folder = new InventoryFolderBase(); | ||
446 | folder.ParentID = rootFolder; | ||
447 | folder.Owner = user; | ||
448 | folder.ID = UUID.Random(); | ||
449 | folder.Name = "Lost And Found"; | ||
450 | folder.Type = (short)AssetType.LostAndFoundFolder; | ||
451 | folder.Version = 1; | ||
452 | Folders.Add(folder.ID, folder); | ||
453 | |||
454 | folder = new InventoryFolderBase(); | ||
455 | folder.ParentID = rootFolder; | ||
456 | folder.Owner = user; | ||
457 | folder.ID = UUID.Random(); | ||
458 | folder.Name = "Notecards"; | ||
459 | folder.Type = (short)AssetType.Notecard; | ||
460 | folder.Version = 1; | ||
461 | Folders.Add(folder.ID, folder); | ||
462 | |||
463 | folder = new InventoryFolderBase(); | ||
464 | folder.ParentID = rootFolder; | ||
465 | folder.Owner = user; | ||
466 | folder.ID = UUID.Random(); | ||
467 | folder.Name = "Objects"; | ||
468 | folder.Type = (short)AssetType.Object; | ||
469 | folder.Version = 1; | ||
470 | Folders.Add(folder.ID, folder); | ||
471 | |||
472 | folder = new InventoryFolderBase(); | ||
473 | folder.ParentID = rootFolder; | ||
474 | folder.Owner = user; | ||
475 | folder.ID = UUID.Random(); | ||
476 | folder.Name = "Photo Album"; | ||
477 | folder.Type = (short)AssetType.SnapshotFolder; | ||
478 | folder.Version = 1; | ||
479 | Folders.Add(folder.ID, folder); | ||
480 | |||
481 | folder = new InventoryFolderBase(); | ||
482 | folder.ParentID = rootFolder; | ||
483 | folder.Owner = user; | ||
484 | folder.ID = UUID.Random(); | ||
485 | folder.Name = "Scripts"; | ||
486 | folder.Type = (short)AssetType.LSLText; | ||
487 | folder.Version = 1; | ||
488 | Folders.Add(folder.ID, folder); | ||
489 | |||
490 | folder = new InventoryFolderBase(); | ||
491 | folder.ParentID = rootFolder; | ||
492 | folder.Owner = user; | ||
493 | folder.ID = UUID.Random(); | ||
494 | folder.Name = "Sounds"; | ||
495 | folder.Type = (short)AssetType.Sound; | ||
496 | folder.Version = 1; | ||
497 | Folders.Add(folder.ID, folder); | ||
498 | |||
499 | folder = new InventoryFolderBase(); | ||
500 | folder.ParentID = rootFolder; | ||
501 | folder.Owner = user; | ||
502 | folder.ID = UUID.Random(); | ||
503 | folder.Name = "Textures"; | ||
504 | folder.Type = (short)AssetType.Texture; | ||
505 | folder.Version = 1; | ||
506 | Folders.Add(folder.ID, folder); | ||
507 | |||
508 | folder = new InventoryFolderBase(); | ||
509 | folder.ParentID = rootFolder; | ||
510 | folder.Owner = user; | ||
511 | folder.ID = UUID.Random(); | ||
512 | folder.Name = "Trash"; | ||
513 | folder.Type = (short)AssetType.TrashFolder; | ||
514 | folder.Version = 1; | ||
515 | Folders.Add(folder.ID, folder); | ||
516 | } | ||
517 | } | ||
518 | } | ||
519 | } | ||
diff --git a/OpenSim/Grid/InventoryServer/Main.cs b/OpenSim/Grid/InventoryServer/Main.cs deleted file mode 100644 index 6106d93..0000000 --- a/OpenSim/Grid/InventoryServer/Main.cs +++ /dev/null | |||
@@ -1,182 +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 System.IO; | ||
31 | using System.Reflection; | ||
32 | using log4net; | ||
33 | using log4net.Config; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim.Framework; | ||
36 | using OpenSim.Framework.Communications.Services; | ||
37 | using OpenSim.Framework.Console; | ||
38 | using OpenSim.Framework.Servers; | ||
39 | using OpenSim.Framework.Servers.HttpServer; | ||
40 | |||
41 | namespace OpenSim.Grid.InventoryServer | ||
42 | { | ||
43 | public class OpenInventory_Main : BaseOpenSimServer | ||
44 | { | ||
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
46 | |||
47 | private GridInventoryService m_inventoryService; | ||
48 | //private HGInventoryService m_directInventoryService; | ||
49 | |||
50 | public const string LogName = "INVENTORY"; | ||
51 | |||
52 | public static void Main(string[] args) | ||
53 | { | ||
54 | XmlConfigurator.Configure(); | ||
55 | |||
56 | OpenInventory_Main theServer = new OpenInventory_Main(); | ||
57 | theServer.Startup(); | ||
58 | |||
59 | theServer.Work(); | ||
60 | } | ||
61 | |||
62 | public OpenInventory_Main() | ||
63 | { | ||
64 | m_console = new LocalConsole("Inventory"); | ||
65 | MainConsole.Instance = m_console; | ||
66 | } | ||
67 | |||
68 | protected override void StartupSpecific() | ||
69 | { | ||
70 | InventoryConfig config = new InventoryConfig(LogName, (Path.Combine(Util.configDir(), "InventoryServer_Config.xml"))); | ||
71 | |||
72 | m_inventoryService = new GridInventoryService(config.UserServerURL); | ||
73 | m_inventoryService.DoLookup = config.SessionLookUp; | ||
74 | m_inventoryService.AddPlugin(config.DatabaseProvider, config.DatabaseConnect); | ||
75 | |||
76 | |||
77 | m_log.Info("[" + LogName + "]: Starting HTTP server ..."); | ||
78 | |||
79 | m_httpServer = new BaseHttpServer(config.HttpPort); | ||
80 | |||
81 | AddHttpHandlers(config.RegionAccessToAgentsInventory); | ||
82 | |||
83 | m_httpServer.Start(); | ||
84 | |||
85 | m_log.Info("[" + LogName + "]: Started HTTP server"); | ||
86 | |||
87 | base.StartupSpecific(); | ||
88 | |||
89 | m_console.Commands.AddCommand("inventoryserver", false, "add user", | ||
90 | "add user", | ||
91 | "Add a random user inventory", HandleAddUser); | ||
92 | } | ||
93 | |||
94 | protected void AddHttpHandlers(bool regionAccess) | ||
95 | { | ||
96 | if (regionAccess) | ||
97 | { | ||
98 | m_httpServer.AddStreamHandler( | ||
99 | new RestDeserialiseSecureHandler<Guid, InventoryCollection>( | ||
100 | "POST", "/GetInventory/", m_inventoryService.GetUserInventory, m_inventoryService.CheckAuthSession)); | ||
101 | |||
102 | m_httpServer.AddStreamHandler( | ||
103 | new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( | ||
104 | "POST", "/UpdateFolder/", m_inventoryService.UpdateFolder, m_inventoryService.CheckAuthSession)); | ||
105 | |||
106 | m_httpServer.AddStreamHandler( | ||
107 | new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( | ||
108 | "POST", "/MoveFolder/", m_inventoryService.MoveFolder, m_inventoryService.CheckAuthSession)); | ||
109 | |||
110 | m_httpServer.AddStreamHandler( | ||
111 | new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( | ||
112 | "POST", "/PurgeFolder/", m_inventoryService.PurgeFolder, m_inventoryService.CheckAuthSession)); | ||
113 | |||
114 | m_httpServer.AddStreamHandler( | ||
115 | new RestDeserialiseSecureHandler<InventoryItemBase, bool>( | ||
116 | "POST", "/DeleteItem/", m_inventoryService.DeleteItem, m_inventoryService.CheckAuthSession)); | ||
117 | |||
118 | m_httpServer.AddStreamHandler( | ||
119 | new RestDeserialiseSecureHandler<InventoryItemBase, InventoryItemBase>( | ||
120 | "POST", "/QueryItem/", m_inventoryService.QueryItem, m_inventoryService.CheckAuthSession)); | ||
121 | |||
122 | m_httpServer.AddStreamHandler( | ||
123 | new RestDeserialiseSecureHandler<InventoryFolderBase, InventoryFolderBase>( | ||
124 | "POST", "/QueryFolder/", m_inventoryService.QueryFolder, m_inventoryService.CheckAuthSession)); | ||
125 | |||
126 | } | ||
127 | |||
128 | m_httpServer.AddStreamHandler( | ||
129 | new RestDeserialiseTrustedHandler<Guid, bool>( | ||
130 | "POST", "/CreateInventory/", m_inventoryService.CreateUsersInventory, m_inventoryService.CheckTrustSource)); | ||
131 | |||
132 | m_httpServer.AddStreamHandler( | ||
133 | new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( | ||
134 | "POST", "/NewFolder/", m_inventoryService.AddFolder, m_inventoryService.CheckAuthSession)); | ||
135 | |||
136 | m_httpServer.AddStreamHandler( | ||
137 | new RestDeserialiseTrustedHandler<InventoryFolderBase, bool>( | ||
138 | "POST", "/CreateFolder/", m_inventoryService.AddFolder, m_inventoryService.CheckTrustSource)); | ||
139 | |||
140 | m_httpServer.AddStreamHandler( | ||
141 | new RestDeserialiseSecureHandler<InventoryItemBase, bool>( | ||
142 | "POST", "/NewItem/", m_inventoryService.AddItem, m_inventoryService.CheckAuthSession)); | ||
143 | |||
144 | m_httpServer.AddStreamHandler( | ||
145 | new RestDeserialiseTrustedHandler<InventoryItemBase, bool>( | ||
146 | "POST", "/AddNewItem/", m_inventoryService.AddItem, m_inventoryService.CheckTrustSource)); | ||
147 | |||
148 | m_httpServer.AddStreamHandler( | ||
149 | new RestDeserialiseTrustedHandler<Guid, List<InventoryItemBase>>( | ||
150 | "POST", "/GetItems/", m_inventoryService.GetFolderItems, m_inventoryService.CheckTrustSource)); | ||
151 | |||
152 | // for persistent active gestures | ||
153 | m_httpServer.AddStreamHandler( | ||
154 | new RestDeserialiseTrustedHandler<Guid, List<InventoryItemBase>> | ||
155 | ("POST", "/ActiveGestures/", m_inventoryService.GetActiveGestures, m_inventoryService.CheckTrustSource)); | ||
156 | |||
157 | // WARNING: Root folders no longer just delivers the root and immediate child folders (e.g | ||
158 | // system folders such as Objects, Textures), but it now returns the entire inventory skeleton. | ||
159 | // It would have been better to rename this request, but complexities in the BaseHttpServer | ||
160 | // (e.g. any http request not found is automatically treated as an xmlrpc request) make it easier | ||
161 | // to do this for now. | ||
162 | m_httpServer.AddStreamHandler( | ||
163 | new RestDeserialiseTrustedHandler<Guid, List<InventoryFolderBase>> | ||
164 | ("POST", "/RootFolders/", m_inventoryService.GetInventorySkeleton, m_inventoryService.CheckTrustSource)); | ||
165 | } | ||
166 | |||
167 | private void Work() | ||
168 | { | ||
169 | m_console.Output("Enter help for a list of commands\n"); | ||
170 | |||
171 | while (true) | ||
172 | { | ||
173 | m_console.Prompt(); | ||
174 | } | ||
175 | } | ||
176 | |||
177 | private void HandleAddUser(string module, string[] args) | ||
178 | { | ||
179 | m_inventoryService.CreateUsersInventory(UUID.Random().Guid); | ||
180 | } | ||
181 | } | ||
182 | } | ||