aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/InventoryService/HGInventoryService.cs
diff options
context:
space:
mode:
authordiva2009-06-07 19:00:55 +0000
committerdiva2009-06-07 19:00:55 +0000
commit1ad237a8a757a0e6074278aff76805d01abf0c0b (patch)
treee6a697dd113aeb90c7dd92ee4d07f278d7ebf8de /OpenSim/Services/InventoryService/HGInventoryService.cs
parentSkip lone ident statments or for-loop assignments (diff)
downloadopensim-SC_OLD-1ad237a8a757a0e6074278aff76805d01abf0c0b.zip
opensim-SC_OLD-1ad237a8a757a0e6074278aff76805d01abf0c0b.tar.gz
opensim-SC_OLD-1ad237a8a757a0e6074278aff76805d01abf0c0b.tar.bz2
opensim-SC_OLD-1ad237a8a757a0e6074278aff76805d01abf0c0b.tar.xz
First draft of inventory service connectors, and service implementation. No handlers yet, this is just the OUT part for now. It's not active and nothing in the simulator uses this yet. Just checking it in to start sharing with others. There are a couple of interesting software design points that could use other devs opinions.
Hopefully I added all needed files.
Diffstat (limited to 'OpenSim/Services/InventoryService/HGInventoryService.cs')
-rw-r--r--OpenSim/Services/InventoryService/HGInventoryService.cs178
1 files changed, 178 insertions, 0 deletions
diff --git a/OpenSim/Services/InventoryService/HGInventoryService.cs b/OpenSim/Services/InventoryService/HGInventoryService.cs
new file mode 100644
index 0000000..e5e40c6
--- /dev/null
+++ b/OpenSim/Services/InventoryService/HGInventoryService.cs
@@ -0,0 +1,178 @@
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
28using log4net;
29using Nini.Config;
30using System;
31using System.Collections.Generic;
32using System.Reflection;
33using OpenSim.Framework;
34using OpenSim.Services.Interfaces;
35using OpenSim.Services.Connectors;
36using OpenMetaverse;
37
38namespace OpenSim.Services.InventoryService
39{
40 public class HGInventoryService : ISessionAuthInventoryService
41 {
42 private static readonly ILog m_log =
43 LogManager.GetLogger(
44 MethodBase.GetCurrentMethod().DeclaringType);
45
46 private Dictionary<string, InventoryServicesConnector> m_connectors = new Dictionary<string, InventoryServicesConnector>();
47
48 public HGInventoryService(IConfigSource source)
49 {
50 IConfig moduleConfig = source.Configs["Modules"];
51 if (moduleConfig != null)
52 {
53
54 IConfig assetConfig = source.Configs["InventoryService"];
55 if (assetConfig == null)
56 {
57 m_log.Error("[HG INVENTORY SERVICE]: InventoryService missing from OpenSim.ini");
58 return;
59 }
60
61 m_log.Info("[HG INVENTORY SERVICE]: HG inventory service enabled");
62 }
63 }
64
65 private bool StringToUrlAndUserID(string id, out string url, out string userID)
66 {
67 url = String.Empty;
68 userID = String.Empty;
69
70 Uri assetUri;
71
72 if (Uri.TryCreate(id, UriKind.Absolute, out assetUri) &&
73 assetUri.Scheme == Uri.UriSchemeHttp)
74 {
75 url = "http://" + assetUri.Authority;
76 userID = assetUri.LocalPath.Trim(new char[] { '/' });
77 return true;
78 }
79
80 return false;
81 }
82 private ISessionAuthInventoryService GetConnector(string url)
83 {
84 InventoryServicesConnector connector = null;
85 lock (m_connectors)
86 {
87 if (m_connectors.ContainsKey(url))
88 {
89 connector = m_connectors[url];
90 }
91 else
92 {
93 // We're instantiating this class explicitly, but this won't
94 // work in general, because the remote grid may be running
95 // an inventory server that has a different protocol.
96 // Eventually we will want a piece of protocol asking
97 // the remote server about its kind. Definitely cool thing to do!
98 connector = new InventoryServicesConnector(url);
99 m_connectors.Add(url, connector);
100 }
101 }
102 return connector;
103 }
104
105 public string Host
106 {
107 get { return string.Empty; }
108 }
109
110 public void GetUserInventory(string id, UUID sessionID, InventoryReceiptCallback callback)
111 {
112 string url = string.Empty;
113 string userID = string.Empty;
114
115 if (StringToUrlAndUserID(id, out url, out userID))
116 {
117 ISessionAuthInventoryService connector = GetConnector(url);
118 connector.GetUserInventory(userID, sessionID, callback);
119 }
120
121 }
122
123 public bool AddFolder(string userID, InventoryFolderBase folder, UUID sessionID)
124 {
125 // TODO
126 return false;
127 }
128
129 public bool UpdateFolder(string userID, InventoryFolderBase folder, UUID sessionID)
130 {
131 // TODO
132 return false;
133 }
134
135 public bool MoveFolder(string userID, InventoryFolderBase folder, UUID sessionID)
136 {
137 // TODO
138 return false;
139 }
140
141 public bool PurgeFolder(string userID, InventoryFolderBase folder, UUID sessionID)
142 {
143 // TODO
144 return false;
145 }
146
147 public bool AddItem(string userID, InventoryItemBase item, UUID sessionID)
148 {
149 // TODO
150 return false;
151 }
152
153 public bool UpdateItem(string userID, InventoryItemBase item, UUID sessionID)
154 {
155 // TODO
156 return false;
157 }
158
159 public bool DeleteItem(string userID, InventoryItemBase item, UUID sessionID)
160 {
161 // TODO
162 return false;
163 }
164
165 public InventoryItemBase QueryItem(string userID, InventoryItemBase item, UUID sessionID)
166 {
167 // TODO
168 return null;
169 }
170
171 public InventoryFolderBase QueryFolder(string userID, InventoryFolderBase folder, UUID sessionID)
172 {
173 // TODO
174 return null;
175 }
176
177 }
178}