aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services
diff options
context:
space:
mode:
authorMelanie2010-10-29 20:40:48 +0100
committerMelanie2010-10-29 20:40:48 +0100
commit9331898c320d7d6046c6d1ad467cdee0e32c8b71 (patch)
tree917ff7facdeb38d96f5f69576a134cbad4776eae /OpenSim/Services
parentMerge branch 'careminster-presence-refactor' of ssh://3dhosting.de/var/git/ca... (diff)
parentMerge branch 'dev-appearance' (diff)
downloadopensim-SC_OLD-9331898c320d7d6046c6d1ad467cdee0e32c8b71.zip
opensim-SC_OLD-9331898c320d7d6046c6d1ad467cdee0e32c8b71.tar.gz
opensim-SC_OLD-9331898c320d7d6046c6d1ad467cdee0e32c8b71.tar.bz2
opensim-SC_OLD-9331898c320d7d6046c6d1ad467cdee0e32c8b71.tar.xz
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Services')
-rw-r--r--OpenSim/Services/AvatarService/AvatarService.cs14
-rw-r--r--OpenSim/Services/Connectors/Avatar/AvatarServiceConnector.cs12
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs82
-rw-r--r--OpenSim/Services/GridService/HypergridLinker.cs47
-rw-r--r--OpenSim/Services/Interfaces/IAvatarService.cs32
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginService.cs10
6 files changed, 164 insertions, 33 deletions
diff --git a/OpenSim/Services/AvatarService/AvatarService.cs b/OpenSim/Services/AvatarService/AvatarService.cs
index 19e662c..a8ad413 100644
--- a/OpenSim/Services/AvatarService/AvatarService.cs
+++ b/OpenSim/Services/AvatarService/AvatarService.cs
@@ -51,6 +51,20 @@ namespace OpenSim.Services.AvatarService
51 m_log.Debug("[AVATAR SERVICE]: Starting avatar service"); 51 m_log.Debug("[AVATAR SERVICE]: Starting avatar service");
52 } 52 }
53 53
54 // Get|SetAppearance should preserve existing semantics
55 // until AvatarData can be removed completely
56 public AvatarAppearance GetAppearance(UUID principalID)
57 {
58 AvatarData avatar = GetAvatar(principalID);
59 return avatar.ToAvatarAppearance(principalID);
60 }
61
62 public bool SetAppearance(UUID principalID, AvatarAppearance appearance)
63 {
64 AvatarData avatar = new AvatarData(appearance);
65 return SetAvatar(principalID,avatar);
66 }
67
54 public AvatarData GetAvatar(UUID principalID) 68 public AvatarData GetAvatar(UUID principalID)
55 { 69 {
56 AvatarBaseData[] av = m_Database.Get("PrincipalID", principalID.ToString()); 70 AvatarBaseData[] av = m_Database.Get("PrincipalID", principalID.ToString());
diff --git a/OpenSim/Services/Connectors/Avatar/AvatarServiceConnector.cs b/OpenSim/Services/Connectors/Avatar/AvatarServiceConnector.cs
index 96c05a9..1cd6bf8 100644
--- a/OpenSim/Services/Connectors/Avatar/AvatarServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Avatar/AvatarServiceConnector.cs
@@ -87,6 +87,18 @@ namespace OpenSim.Services.Connectors
87 87
88 #region IAvatarService 88 #region IAvatarService
89 89
90 public AvatarAppearance GetAppearance(UUID userID)
91 {
92 AvatarData avatar = GetAvatar(userID);
93 return avatar.ToAvatarAppearance(userID);
94 }
95
96 public bool SetAppearance(UUID userID, AvatarAppearance appearance)
97 {
98 AvatarData avatar = new AvatarData(appearance);
99 return SetAvatar(userID,avatar);
100 }
101
90 public AvatarData GetAvatar(UUID userID) 102 public AvatarData GetAvatar(UUID userID)
91 { 103 {
92 Dictionary<string, object> sendData = new Dictionary<string, object>(); 104 Dictionary<string, object> sendData = new Dictionary<string, object>();
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs
index 4d0d53e..ea9b4b4 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs
@@ -28,6 +28,9 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Collections.Specialized; 30using System.Collections.Specialized;
31// DEBUG ON
32using System.Diagnostics;
33// DEBUG OFF
31using System.Reflection; 34using System.Reflection;
32using log4net; 35using log4net;
33using Mono.Addins; 36using Mono.Addins;
@@ -106,6 +109,80 @@ namespace OpenSim.Services.Connectors.SimianGrid
106 109
107 #region IAvatarService 110 #region IAvatarService
108 111
112 // <summary>
113 // Retrieves the LLPackedAppearance field from user data and unpacks
114 // it into an AvatarAppearance structure
115 // </summary>
116 // <param name="userID"></param>
117 public AvatarAppearance GetAppearance(UUID userID)
118 {
119 NameValueCollection requestArgs = new NameValueCollection
120 {
121 { "RequestMethod", "GetUser" },
122 { "UserID", userID.ToString() }
123 };
124
125 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
126 if (response["Success"].AsBoolean())
127 {
128 OSDMap map = null;
129 try { map = OSDParser.DeserializeJson(response["LLPackedAppearance"].AsString()) as OSDMap; }
130 catch { }
131
132 if (map != null)
133 {
134 AvatarAppearance appearance = new AvatarAppearance(map);
135// DEBUG ON
136 m_log.WarnFormat("[SIMIAN AVATAR CONNECTOR] retrieved appearance for {0}:\n{1}",userID,appearance.ToString());
137// DEBUG OFF
138 return appearance;
139 }
140
141 m_log.WarnFormat("[SIMIAN AVATAR CONNECTOR]: Failed to decode appearance for {0}",userID);
142 return null;
143 }
144
145 m_log.WarnFormat("[SIMIAN AVATAR CONNECTOR]: Failed to get appearance for {0}: {1}",
146 userID,response["Message"].AsString());
147 return null;
148 }
149
150 // <summary>
151 // </summary>
152 // <param name=""></param>
153 public bool SetAppearance(UUID userID, AvatarAppearance appearance)
154 {
155 OSDMap map = appearance.Pack();
156 if (map == null)
157 {
158 m_log.WarnFormat("[SIMIAN AVATAR CONNECTOR]: Failed to encode appearance for {0}",userID);
159 return false;
160 }
161
162// DEBUG ON
163 m_log.WarnFormat("[SIMIAN AVATAR CONNECTOR] save appearance for {0}",userID);
164// DEBUG OFF
165
166 NameValueCollection requestArgs = new NameValueCollection
167 {
168 { "RequestMethod", "AddUserData" },
169 { "UserID", userID.ToString() },
170 { "LLPackedAppearance", OSDParser.SerializeJsonString(map) }
171 };
172
173 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
174 bool success = response["Success"].AsBoolean();
175
176 if (! success)
177 m_log.WarnFormat("[SIMIAN AVATAR CONNECTOR]: Failed to save appearance for {0}: {1}",
178 userID,response["Message"].AsString());
179
180 return success;
181 }
182
183 // <summary>
184 // </summary>
185 // <param name=""></param>
109 public AvatarData GetAvatar(UUID userID) 186 public AvatarData GetAvatar(UUID userID)
110 { 187 {
111 NameValueCollection requestArgs = new NameValueCollection 188 NameValueCollection requestArgs = new NameValueCollection
@@ -154,7 +231,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
154 foreach (KeyValuePair<string, OSD> kvp in map) 231 foreach (KeyValuePair<string, OSD> kvp in map)
155 avatar.Data[kvp.Key] = kvp.Value.AsString(); 232 avatar.Data[kvp.Key] = kvp.Value.AsString();
156 } 233 }
157 234
158 return avatar; 235 return avatar;
159 } 236 }
160 else 237 else
@@ -173,6 +250,9 @@ namespace OpenSim.Services.Connectors.SimianGrid
173 return null; 250 return null;
174 } 251 }
175 252
253 // <summary>
254 // </summary>
255 // <param name=""></param>
176 public bool SetAvatar(UUID userID, AvatarData avatar) 256 public bool SetAvatar(UUID userID, AvatarData avatar)
177 { 257 {
178 m_log.Debug("[SIMIAN AVATAR CONNECTOR]: SetAvatar called for " + userID); 258 m_log.Debug("[SIMIAN AVATAR CONNECTOR]: SetAvatar called for " + userID);
diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs
index b86fb6f..a67404f 100644
--- a/OpenSim/Services/GridService/HypergridLinker.cs
+++ b/OpenSim/Services/GridService/HypergridLinker.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Linq;
30using System.Net; 31using System.Net;
31using System.Reflection; 32using System.Reflection;
32using System.Xml; 33using System.Xml;
@@ -154,6 +155,11 @@ namespace OpenSim.Services.GridService
154 // From the command line link-region 155 // From the command line link-region
155 public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, out string reason) 156 public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, out string reason)
156 { 157 {
158 return TryLinkRegionToCoords(scopeID, mapName, xloc, yloc, UUID.Zero, out reason);
159 }
160
161 public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, UUID ownerID, out string reason)
162 {
157 reason = string.Empty; 163 reason = string.Empty;
158 string host = "127.0.0.1"; 164 string host = "127.0.0.1";
159 string portstr; 165 string portstr;
@@ -189,7 +195,7 @@ namespace OpenSim.Services.GridService
189 //} 195 //}
190 196
191 GridRegion regInfo; 197 GridRegion regInfo;
192 bool success = TryCreateLink(scopeID, xloc, yloc, regionName, port, host, out regInfo, out reason); 198 bool success = TryCreateLink(scopeID, xloc, yloc, regionName, port, host, ownerID, out regInfo, out reason);
193 if (success) 199 if (success)
194 { 200 {
195 regInfo.RegionName = mapName; 201 regInfo.RegionName = mapName;
@@ -202,7 +208,8 @@ namespace OpenSim.Services.GridService
202 208
203 // From the command line and the 2 above 209 // From the command line and the 2 above
204 public bool TryCreateLink(UUID scopeID, int xloc, int yloc, 210 public bool TryCreateLink(UUID scopeID, int xloc, int yloc,
205 string externalRegionName, uint externalPort, string externalHostName, out GridRegion regInfo, out string reason) 211 string externalRegionName, uint externalPort, string externalHostName, UUID ownerID,
212 out GridRegion regInfo, out string reason)
206 { 213 {
207 m_log.DebugFormat("[HYPERGRID LINKER]: Link to {0}:{1}:{2}, in {3}-{4}", externalHostName, externalPort, externalRegionName, xloc, yloc); 214 m_log.DebugFormat("[HYPERGRID LINKER]: Link to {0}:{1}:{2}, in {3}-{4}", externalHostName, externalPort, externalRegionName, xloc, yloc);
208 215
@@ -214,12 +221,22 @@ namespace OpenSim.Services.GridService
214 regInfo.RegionLocX = xloc; 221 regInfo.RegionLocX = xloc;
215 regInfo.RegionLocY = yloc; 222 regInfo.RegionLocY = yloc;
216 regInfo.ScopeID = scopeID; 223 regInfo.ScopeID = scopeID;
224 regInfo.EstateOwner = ownerID;
217 225
218 // Big HACK for Simian Grid !!! 226 // Big HACK for Simian Grid !!!
219 // We need to clean up all URLs used in OpenSim !!! 227 // We need to clean up all URLs used in OpenSim !!!
220 if (externalHostName.Contains("/")) 228 if (externalHostName.Contains("/"))
221 regInfo.ServerURI = externalHostName; 229 regInfo.ServerURI = externalHostName;
222 230
231 // Check for free coordinates
232 GridRegion region = m_GridService.GetRegionByPosition(regInfo.ScopeID, regInfo.RegionLocX, regInfo.RegionLocY);
233 if (region != null)
234 {
235 m_log.WarnFormat("[HYPERGRID LINKER]: Coordinates {0}-{1} are already occupied by region {2} with uuid {3}", regInfo.RegionLocX, regInfo.RegionLocY, region.RegionName, region.RegionID);
236 reason = "Coordinates are already in use";
237 return false;
238 }
239
223 try 240 try
224 { 241 {
225 regInfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)0); 242 regInfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)0);
@@ -241,11 +258,11 @@ namespace OpenSim.Services.GridService
241 258
242 if (regionID != UUID.Zero) 259 if (regionID != UUID.Zero)
243 { 260 {
244 GridRegion r = m_GridService.GetRegionByUUID(scopeID, regionID); 261 region = m_GridService.GetRegionByUUID(scopeID, regionID);
245 if (r != null) 262 if (region != null)
246 { 263 {
247 m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates {0} {1}", r.RegionLocX / Constants.RegionSize, r.RegionLocY / Constants.RegionSize); 264 m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates {0} {1}", region.RegionLocX / Constants.RegionSize, region.RegionLocY / Constants.RegionSize);
248 regInfo = r; 265 regInfo = region;
249 return true; 266 return true;
250 } 267 }
251 268
@@ -355,17 +372,8 @@ namespace OpenSim.Services.GridService
355 { 372 {
356 // Check for regions which are not linked regions 373 // Check for regions which are not linked regions
357 List<GridRegion> hyperlinks = m_GridService.GetHyperlinks(m_ScopeID); 374 List<GridRegion> hyperlinks = m_GridService.GetHyperlinks(m_ScopeID);
358 // would like to use .Except, but doesn't seem to exist 375 IEnumerable<GridRegion> availableRegions = regions.Except(hyperlinks);
359 //IEnumerable<GridRegion> availableRegions = regions.Except(hyperlinks); 376 if (availableRegions.Count() == 0)
360 List<GridRegion> availableRegions = regions.FindAll(delegate(GridRegion region)
361 {
362 // Ewww! n^2
363 if (hyperlinks.Find(delegate(GridRegion r) { return r.RegionID == region.RegionID; }) == null) // not hyperlink. good.
364 return true;
365
366 return false;
367 });
368 if (availableRegions.Count == 0)
369 return false; 377 return false;
370 } 378 }
371 379
@@ -529,7 +537,7 @@ namespace OpenSim.Services.GridService
529 xloc = xloc * (int)Constants.RegionSize; 537 xloc = xloc * (int)Constants.RegionSize;
530 yloc = yloc * (int)Constants.RegionSize; 538 yloc = yloc * (int)Constants.RegionSize;
531 string reason = string.Empty; 539 string reason = string.Empty;
532 if (TryCreateLink(UUID.Zero, xloc, yloc, "", externalPort, externalHostName, out regInfo, out reason)) 540 if (TryCreateLink(UUID.Zero, xloc, yloc, "", externalPort, externalHostName, UUID.Zero, out regInfo, out reason))
533 { 541 {
534 if (cmdparams.Length >= 5) 542 if (cmdparams.Length >= 5)
535 { 543 {
@@ -631,8 +639,7 @@ namespace OpenSim.Services.GridService
631 xloc = xloc * (int)Constants.RegionSize; 639 xloc = xloc * (int)Constants.RegionSize;
632 yloc = yloc * (int)Constants.RegionSize; 640 yloc = yloc * (int)Constants.RegionSize;
633 string reason = string.Empty; 641 string reason = string.Empty;
634 if (TryCreateLink(UUID.Zero, xloc, yloc, "", externalPort, 642 if (TryCreateLink(UUID.Zero, xloc, yloc, "", externalPort, externalHostName, UUID.Zero, out regInfo, out reason))
635 externalHostName, out regInfo, out reason))
636 { 643 {
637 regInfo.RegionName = config.GetString("localName", ""); 644 regInfo.RegionName = config.GetString("localName", "");
638 } 645 }
diff --git a/OpenSim/Services/Interfaces/IAvatarService.cs b/OpenSim/Services/Interfaces/IAvatarService.cs
index de3bcf9..93b977b 100644
--- a/OpenSim/Services/Interfaces/IAvatarService.cs
+++ b/OpenSim/Services/Interfaces/IAvatarService.cs
@@ -42,6 +42,21 @@ namespace OpenSim.Services.Interfaces
42 /// </summary> 42 /// </summary>
43 /// <param name="userID"></param> 43 /// <param name="userID"></param>
44 /// <returns></returns> 44 /// <returns></returns>
45 AvatarAppearance GetAppearance(UUID userID);
46
47 /// <summary>
48 /// Called by everyone who can change the avatar data (so, regions)
49 /// </summary>
50 /// <param name="userID"></param>
51 /// <param name="appearance"></param>
52 /// <returns></returns>
53 bool SetAppearance(UUID userID, AvatarAppearance appearance);
54
55 /// <summary>
56 /// Called by the login service
57 /// </summary>
58 /// <param name="userID"></param>
59 /// <returns></returns>
45 AvatarData GetAvatar(UUID userID); 60 AvatarData GetAvatar(UUID userID);
46 61
47 /// <summary> 62 /// <summary>
@@ -217,23 +232,26 @@ namespace OpenSim.Services.Interfaces
217 foreach (KeyValuePair<string, string> _kvp in Data) 232 foreach (KeyValuePair<string, string> _kvp in Data)
218 if (_kvp.Key.StartsWith("_ap_")) 233 if (_kvp.Key.StartsWith("_ap_"))
219 attchs[_kvp.Key] = _kvp.Value; 234 attchs[_kvp.Key] = _kvp.Value;
220 Hashtable aaAttachs = new Hashtable(); 235
221 foreach (KeyValuePair<string, string> _kvp in attchs) 236 foreach (KeyValuePair<string, string> _kvp in attchs)
222 { 237 {
223 string pointStr = _kvp.Key.Substring(4); 238 string pointStr = _kvp.Key.Substring(4);
224 int point = 0; 239 int point = 0;
225 if (!Int32.TryParse(pointStr, out point)) 240 if (!Int32.TryParse(pointStr, out point))
226 continue; 241 continue;
227 Hashtable tmp = new Hashtable(); 242
228 UUID uuid = UUID.Zero; 243 UUID uuid = UUID.Zero;
229 UUID.TryParse(_kvp.Value, out uuid); 244 UUID.TryParse(_kvp.Value, out uuid);
230 tmp["item"] = uuid; 245
231 tmp["asset"] = UUID.Zero.ToString(); 246 appearance.SetAttachment(point,uuid,UUID.Zero);
232 aaAttachs[point] = tmp;
233 } 247 }
234 appearance.SetAttachments(aaAttachs);
235 } 248 }
236 catch { } 249 catch
250 {
251 // We really should report something here, returning null
252 // will at least break the wrapper
253 return null;
254 }
237 255
238 return appearance; 256 return appearance;
239 } 257 }
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs
index 6c66414..1d3c412 100644
--- a/OpenSim/Services/LLLoginService/LLLoginService.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginService.cs
@@ -336,10 +336,10 @@ namespace OpenSim.Services.LLLoginService
336 // 336 //
337 // Get the avatar 337 // Get the avatar
338 // 338 //
339 AvatarData avatar = null; 339 AvatarAppearance avatar = null;
340 if (m_AvatarService != null) 340 if (m_AvatarService != null)
341 { 341 {
342 avatar = m_AvatarService.GetAvatar(account.PrincipalID); 342 avatar = m_AvatarService.GetAppearance(account.PrincipalID);
343 } 343 }
344 344
345 // 345 //
@@ -607,7 +607,7 @@ namespace OpenSim.Services.LLLoginService
607 } 607 }
608 } 608 }
609 609
610 protected AgentCircuitData LaunchAgentAtGrid(GridRegion gatekeeper, GridRegion destination, UserAccount account, AvatarData avatar, 610 protected AgentCircuitData LaunchAgentAtGrid(GridRegion gatekeeper, GridRegion destination, UserAccount account, AvatarAppearance avatar,
611 UUID session, UUID secureSession, Vector3 position, string currentWhere, string viewer, string channel, string mac, string id0, 611 UUID session, UUID secureSession, Vector3 position, string currentWhere, string viewer, string channel, string mac, string id0,
612 IPEndPoint clientIP, out string where, out string reason, out GridRegion dest) 612 IPEndPoint clientIP, out string where, out string reason, out GridRegion dest)
613 { 613 {
@@ -703,14 +703,14 @@ namespace OpenSim.Services.LLLoginService
703 } 703 }
704 704
705 private AgentCircuitData MakeAgent(GridRegion region, UserAccount account, 705 private AgentCircuitData MakeAgent(GridRegion region, UserAccount account,
706 AvatarData avatar, UUID session, UUID secureSession, uint circuit, Vector3 position, 706 AvatarAppearance avatar, UUID session, UUID secureSession, uint circuit, Vector3 position,
707 string ipaddress, string viewer, string channel, string mac, string id0) 707 string ipaddress, string viewer, string channel, string mac, string id0)
708 { 708 {
709 AgentCircuitData aCircuit = new AgentCircuitData(); 709 AgentCircuitData aCircuit = new AgentCircuitData();
710 710
711 aCircuit.AgentID = account.PrincipalID; 711 aCircuit.AgentID = account.PrincipalID;
712 if (avatar != null) 712 if (avatar != null)
713 aCircuit.Appearance = avatar.ToAvatarAppearance(account.PrincipalID); 713 aCircuit.Appearance = new AvatarAppearance(avatar);
714 else 714 else
715 aCircuit.Appearance = new AvatarAppearance(account.PrincipalID); 715 aCircuit.Appearance = new AvatarAppearance(account.PrincipalID);
716 716